From a40be1135bf31caf4f95ecce9d108d665d2a7ac4 Mon Sep 17 00:00:00 2001 From: Haresh Shyara Date: Thu, 22 Jun 2017 14:55:22 +0530 Subject: [PATCH] [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) --- addons/product/models/product.py | 3 ++- addons/product/models/product_template.py | 3 ++- addons/product/views/product_views.xml | 8 +++++--- addons/purchase/views/purchase_views.xml | 7 +++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 8e63236e48d..51c826499a1 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -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.") diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index af1cf89c871..1d36d506e75 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -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') diff --git a/addons/product/views/product_views.xml b/addons/product/views/product_views.xml index 2872a7bfd61..80d25e411d7 100644 --- a/addons/product/views/product_views.xml +++ b/addons/product/views/product_views.xml @@ -48,8 +48,8 @@ -