[IMP] product, purchase: allow to set vendor prices on specific variant

- Show Product(product.supplierinfo) field when product has more than one variants.
- Improve tooltip on Product(product.supplierinfo) and 'Cost'(product.template) fields.
- Hide 'Cost'(product.template) field when product has more than one variant

Purpose
=======

1. There is some confusion between the vendor price and the cost price of a product. The goal of this task is to clarify it for users.
2. Some users would like to set up vendor prices specific to a variant, the goal of this task is to allow them to do that.

Specification
=============

- Add a clear tooltip on the Cost field (standard_price) : "The cost price is used to valuate your inventory."
- When creating variants, it is impossible to set the cost of the product variant, it always resets to 0. It should be hidden if the product has some variants
- Add product_id o2m in vendors form, tree view on product template, and same field should be displayed on variant form view (the field is not required)
- Product_id field visible only when product has more than one variant
- Add a tooltip on this field : "If not set, the vendor price will apply to all variants of this products."
- Vendor price calculation for automated generated RFQ (should be based on sequence: take the first vendor price that matches all the conditions)
This commit is contained in:
Haresh Shyara
2017-08-09 16:55:15 +02:00
committed by Yannick Tivisse
parent 26786dba68
commit a40be1135b
4 changed files with 14 additions and 7 deletions
+2 -1
View File
@@ -595,10 +595,11 @@ class SupplierInfo(models.Model):
date_end = fields.Date('End Date', help="End date for this vendor price")
product_id = fields.Many2one(
'product.product', 'Product Variant',
help="When this field is filled in, the vendor data will only apply to the variant.")
help="If not set, the vendor price will apply to all variants of this products.")
product_tmpl_id = fields.Many2one(
'product.template', 'Product Template',
index=True, ondelete='cascade', oldname='product_id')
product_variant_count = fields.Integer('Variant Count', related='product_tmpl_id.product_variant_count')
delay = fields.Integer(
'Delivery Lead Time', default=1, required=True,
help="Lead time in days between the confirmation of the purchase order and the receipt of the products in your warehouse. Used by the scheduler for automatic computation of the purchase order planning.")
+2 -1
View File
@@ -78,7 +78,7 @@ class ProductTemplate(models.Model):
'Cost', compute='_compute_standard_price',
inverse='_set_standard_price', search='_search_standard_price',
digits=dp.get_precision('Product Price'), groups="base.group_user",
help="Cost of the product, in the default unit of measure of the product.")
help="The cost price is used to valuate your inventory.")
volume = fields.Float(
'Volume', compute='_compute_volume', inverse='_set_volume',
@@ -110,6 +110,7 @@ class ProductTemplate(models.Model):
'product.packaging', string="Product Packages", compute="_compute_packaging_ids", inverse="_set_packaging_ids",
help="Gives the different ways to package the same product.")
seller_ids = fields.One2many('product.supplierinfo', 'product_tmpl_id', 'Vendors')
variant_seller_ids = fields.One2many('product.supplierinfo', 'product_tmpl_id')
active = fields.Boolean('Active', default=True, help="If unchecked, it will allow you to hide the product without removing it.")
color = fields.Integer('Color Index')
+5 -3
View File
@@ -48,8 +48,8 @@
</group>
<group name="group_standard_price">
<field name="list_price" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<label for="standard_price" groups="base.group_user"/>
<div name="standard_price_uom" groups="base.group_user">
<label for="standard_price" groups="base.group_user" attrs="{'invisible': [('product_variant_count', '&gt;', 1)]}"/>
<div name="standard_price_uom" groups="base.group_user" attrs="{'invisible': [('product_variant_count', '&gt;', 1)]}">
<field name="standard_price" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</div>
<field name="company_id" groups="base.group_multi_company"
@@ -502,10 +502,11 @@
<form string="Vendor Information">
<group>
<group string="Vendor">
<field name="product_variant_count" invisible="1"/>
<field name="product_id" attrs="{'invisible': [('product_variant_count', '&lt;=', 1)]}" groups="product.group_product_variant" domain="[('product_tmpl_id', '=', product_tmpl_id)]"/>
<field name="name" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"/>
<field name="product_name"/>
<field name="product_code"/>
<field name="product_id" domain="[('product_tmpl_id', '=', product_tmpl_id)]" invisible="1"/>
<label for="delay"/>
<div>
<field name="delay" class="oe_inline"/> days
@@ -557,6 +558,7 @@
<tree string="Vendor Information">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="product_id" groups="product.group_product_variant"/>
<field name="product_tmpl_id" string="Product" invisible="context.get('visible_product_tmpl_id', True)"/>
<field name="min_qty"/>
<field name="price" string="Price"/>
+5 -2
View File
@@ -557,8 +557,11 @@
<field name="arch" type="xml">
<page name="sales" position="after">
<page string="Purchase" name="purchase" attrs="{'invisible': [('purchase_ok','=',False)]}">
<group string="Vendors" name="vendors">
<field name="seller_ids" context="{'default_product_tmpl_id': context.get('product_tmpl_id', active_id)}" nolabel="1"/>
<group string="Vendors" name="vendors" attrs="{'invisible': [('product_variant_count','&gt;',1)]}">
<field name="seller_ids" context="{'default_product_tmpl_id':context.get('product_tmpl_id',active_id)}" nolabel="1"/>
</group>
<group string="Vendors" name="variant_vendors" attrs="{'invisible': [('product_variant_count','&lt;=',1)]}">
<field name="variant_seller_ids" context="{'default_product_tmpl_id': context.get('product_tmpl_id', active_id)}, 'tree_view_ref': 'product.product_supplierinfo_tree_view'" nolabel="1"/>
</group>
</page>
</page>