Contributors mailing list archives
contributors@odoo-community.org
Browse archives
Re: Vendor Pricelist records for Product Variants - what am I missing?
byGraeme,
I perfectly undertsand the design of product.supplierinfo and have no problem dealing with date_end (I created a small module that upon creation of new record end the existing ones with the same combination of attributes)
What puzzles me is the design from the side of product.template and/or product.product side. You see there are basically 2 identical one2many attributes (so actually no database tables / columns are created) on product.template that reference product.supplierinfo: seller_ids and variant_seller_ids:
seller_ids = fields.One2many('product.supplierinfo', 'product_tmpl_id', 'Vendors', help="Define vendor pricelists.")
variant_seller_ids = fields.One2many('product.supplierinfo', 'product_tmpl_id')
As the name would suggest the latter should somehow provide info on sellers of variants. But it does not in any way. The variant_seller_ids is never used in code. It is only referenced in one view where it is displayed instead of seller_ids in purchase/views/product_views.xml when there are more than 1 variants of that product:
<field name="seller_ids" context="{'default_product_tmpl_id':context.get('product_tmpl_id',active_id), 'product_template_invisible_variant': True}" nolabel="1" attrs="{'invisible': [('product_variant_count','>',1)]}"/>
<field name="variant_seller_ids" context="{'default_product_tmpl_id': context.get('product_tmpl_id', active_id)}" nolabel="1" attrs="{'invisible': [('product_variant_count','<=',1)]}"/>
But it still shows the same thing as seller_ids would! According to a comment on PR that introduced this back in June 2017 in version 11.0 from sswapnesh (who I believe is best Odoo contributor for years 2019, 2020 and 202) this does not make sense as well. Just see it there - tho comment is from August 2020. I believe the variant_seller_ids should have been defined in product.product and the name of its inverse filed should have been product_id. Or something similar.
I stumbled upon this situation when attempting to import-update product variant and also create new corresponding record for product.supplierinfo. It seems that's impossible. Why? Because there is no one2many relation between product.product and product.supplierinfo. I do not believe this was intended.
Am I making sense? Do those 2 attributes together make sense in context of product.supplierinfo? Not to me.
Best regards
Radovan
On štvrtok 20. januára 2022 20:56:57 CET Graeme Gellatly wrote:
> In general when you do lots of seller pricelist you enable Vendor Pricelists
> and import from there. The end date problem is still a problem. You can
> kind of get around it with sequences, start dates on new records and then
> find dups after. It would be good to have a specific module to do
> everything. But supplierinfo is straightforward. Those are the fields you
> care about. Not product template relational references. Do it via vendor
> pricelists and much easier. product_id = fields . Many2one (
> 'product.product' , 'Product Variant' , check_company = True , help = "If
> not set, the vendor price will apply to all variants of this product." )
> product_tmpl_id = fields . Many2one ( 'product.template' , 'Product
> Template' , check_company = True , index = True , ondelete =
> 'cascade' ) On Thu, Jan 20, 2022 at 10:27 PM Radovan Skolnik <
> radovan@skolnik.info [1] > wrote: What's more the field variant_seller_ids
> is never used anywhere besides that view. It was introduced into 11.0 by
> this PR: https://github.com/odoo/odoo/pull/17789 [2]
>
> R.S.
>
> On štvrtok 20. januára 2022 8:32:15 CET Radovan Skolnik wrote:
> > Hello,
> >
> > as New Year came it fell upon me to update lots of pricelists. As we use
> > Product Variants (product.product) quite a bit I am invalidating (i.e.
> > setting date_end) on existing Supplier Pricelist (product.supplierinfo)
> > records and creating new ones. Using base_import_match to match the
> > correct
> > product variant by internal reference (default_code) and trying to import
> > related product.supplierinfo record. Originally I wanted to create small
> > helper that would invalidate all existing records (no end date, same
> > variant, same template, same supplier, same company) when creating new
> > one.
> > Just to save time updating existing records and creating new ones. However
> > it never works (more on that below).
> >
> > Now there are 2 fields defined for product.template and none for
> > product.product that would serve what I am wanting to do. Here's what's
> > defined for product.template (in 13.0, 14.0 and 15.0 as well): seller_ids
> > =
> > fields.One2many('product.supplierinfo', 'product_tmpl_id', 'Vendors',
> > depends_context=('company',), help="Define vendor pricelists.")
> > variant_seller_ids = fields.One2many('product.supplierinfo',
> > 'product_tmpl_id')
> >
> > In Purchase there is this for product.template view:
> > <field name="seller_ids"
> > context="{'default_product_tmpl_id':context.get('product_tmpl_id',active_i
> > d
> > ), 'product_template_invisible_variant': True}" nolabel="1"
> > attrs="{'invisible': [('product_variant_count','>',1)]}"/> <field
> > name="variant_seller_ids" context="{'default_product_tmpl_id':
> > context.get('product_tmpl_id', active_id)}" nolabel="1"
> > attrs="{'invisible': [('product_variant_count','<=',1)]}"/>
> >
> > Just for clarity, here's part from product.supplierinfo:
> > product_id = fields.Many2one('product.product', 'Product Variant',
> > check_company=True, help="If not set, the vendor price will apply to all
> > variants of this product.") product_tmpl_id =
> > fields.Many2one('product.template', 'Product Template',
> > check_company=True,
> > index=True, ondelete='cascade')
> >
> > Am I missing something here or are these the same besides the context and
> > some witchcraft in views? While trying to import the product.product
> > records when creating product.supplierinfo records there's always
> > product_tmpl_id but never product_id. Shouldn't the definition of
> > variant_s
> > be like this and defined in product.product model: variant_seller_ids =
> > fields.One2many('product.supplierinfo', ' *product_id* ')
> >
> > What is the purpose of current design? Would anyone be willing to shed
> > some
> > light here? Hope such post fits in the mailing list.
> >
> > Thank you very much.Best regards
> >
> > Radovan Skolnik
> >
> > _______________________________________________
> > Mailing-List: https://odoo-community.org/groups/contributors-15 [3] [1]
> > Post to: mailto: contributors@odoo-community.org [4]
> > Unsubscribe: https://odoo-community.org/groups?unsubscribe [5] [2]
> >
> >
> >
> > [1] https://odoo-community.org/groups/contributors-15 [6]
> > [2] https://odoo-community.org/groups?unsubscribe [7]
>
> _______________________________________________
> Mailing-List: https://odoo-community.org/groups/contributors-15 [8]
> Post to: mailto: contributors@odoo-community.org [9]
> Unsubscribe: https://odoo-community.org/groups?unsubscribe [10]
>
>
> _______________________________________________
> Mailing-List: https://odoo-community.org/groups/contributors-15 [11]
> Post to: mailto:contributors@odoo-community.org
> Unsubscribe: https://odoo-community.org/groups?unsubscribe [12]
>
>
>
> [1] mailto:radovan@skolnik.info
> [2] https://github.com/odoo/odoo/pull/17789
> [3] https://odoo-community.org/groups/contributors-15
> [4] mailto:contributors@odoo-community.org
> [5] https://odoo-community.org/groups?unsubscribe
> [6] https://odoo-community.org/groups/contributors-15
> [7] https://odoo-community.org/groups?unsubscribe
> [8] https://odoo-community.org/groups/contributors-15
> [9] mailto:contributors@odoo-community.org
> [10] https://odoo-community.org/groups?unsubscribe
> [11] https://odoo-community.org/groups/contributors-15
> [12] https://odoo-community.org/groups?unsubscribe
Reference
-
Vendor Pricelist records for Product Variants - what am I missing?
byData Dance s.r.o., Radovan Skolnik-
Re: Vendor Pricelist records for Product Variants - what am I missing?
byData Dance s.r.o., Radovan Skolnik -
Re: Vendor Pricelist records for Product Variants - what am I missing?
byMoaHub, Graeme Gellatly -
Re: Vendor Pricelist records for Product Variants - what am I missing?
byData Dance s.r.o., Radovan Skolnik
-