From af9d21b379f1dd42e83dcfa164af489c9261542d Mon Sep 17 00:00:00 2001 From: Prashent Panchal Date: Tue, 18 Aug 2015 17:39:17 +0200 Subject: [PATCH] [REF] product: update and form cleaning Among a lot of views tweakings and cleaning, some changes are listed here. product - add currency_id, taken from the company stock - procurement request and inveotry adjustement wizards now correctly work on product and templates with 1 or more variants. With one product the product field is readonly, with a template and/or a product with variants the product field is limited to the existing varians. - valuation and cost method fields on the templates now come from property fields defined on the template, or from property fields defined on the product category. It allows to define those fields directly from the category.Among a lot of views tweakings and cleaning, some changes are listed here. membership - details not visible in the default product view. However there is a specific view to use in (membership / configuration / create member product) --- addons/account/views/product_view.xml | 19 +- .../views/account_asset_view.xml | 19 +- addons/membership/membership_view.xml | 18 -- addons/point_of_sale/point_of_sale_view.xml | 6 +- addons/product/__openerp__.py | 2 +- addons/product/product.py | 28 +- addons/product/product_view.xml | 296 ++++++++---------- .../views/product_view.xml | 12 +- addons/product_expiry/product_expiry_view.xml | 6 +- .../product_extended_view.xml | 15 +- addons/project/project_view.xml | 16 +- addons/purchase/purchase_view.xml | 9 +- .../report_intrastat_view.xml | 2 +- addons/sale/sale_view.xml | 6 +- .../views/product_template_view.xml | 4 +- .../sale_service/views/sale_service_view.xml | 13 +- addons/stock/__openerp__.py | 2 +- addons/stock/product.py | 20 +- addons/stock/product_view.xml | 233 ++++++++------ addons/stock/report/report_stock_forecast.py | 1 + addons/stock/report/report_stock_forecast.xml | 5 +- addons/stock/report/report_stock_view.xml | 3 +- addons/stock/stock.py | 12 - addons/stock/stock_view.xml | 71 +++-- .../stock/wizard/make_procurement_product.py | 54 ++-- addons/stock/wizard/make_procurement_view.xml | 7 +- .../stock/wizard/stock_change_product_qty.py | 42 ++- .../wizard/stock_change_product_qty_view.xml | 7 +- addons/stock_account/product.py | 89 +++++- addons/stock_account/product_view.xml | 54 ++-- addons/stock_account/stock_account_data.xml | 19 +- addons/stock_landed_costs/product_view.xml | 19 +- addons/warning/warning_view.xml | 26 +- addons/website_sale/views/views.xml | 15 +- .../views/website_sale_digital_view.xml | 12 - 35 files changed, 604 insertions(+), 558 deletions(-) diff --git a/addons/account/views/product_view.xml b/addons/account/views/product_view.xml index a44b0b4b29b..d2e57a9a84f 100644 --- a/addons/account/views/product_view.xml +++ b/addons/account/views/product_view.xml @@ -9,20 +9,21 @@ - - - - + + - - + + + @@ -35,7 +36,7 @@ - + diff --git a/addons/account_asset/views/account_asset_view.xml b/addons/account_asset/views/account_asset_view.xml index 389659fe9c1..39c51be33ff 100644 --- a/addons/account_asset/views/account_asset_view.xml +++ b/addons/account_asset/views/account_asset_view.xml @@ -229,16 +229,21 @@ Product Template (form) product.template - + - - - - - + + + + + + - + Journal Entries (form) account.move diff --git a/addons/membership/membership_view.xml b/addons/membership/membership_view.xml index 879f2102ceb..8978a7568c7 100644 --- a/addons/membership/membership_view.xml +++ b/addons/membership/membership_view.xml @@ -80,24 +80,6 @@ - - Membership Products - product.template - 6 - - - - - - - - - - - - - - Membership Products product.template diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml index d1b7af2eee0..e924e5126e8 100644 --- a/addons/point_of_sale/point_of_sale_view.xml +++ b/addons/point_of_sale/point_of_sale_view.xml @@ -544,11 +544,11 @@ product.template - + - - + + diff --git a/addons/product/__openerp__.py b/addons/product/__openerp__.py index 173ae072784..c9a922d1f48 100644 --- a/addons/product/__openerp__.py +++ b/addons/product/__openerp__.py @@ -4,7 +4,7 @@ { 'name': 'Products & Pricelists', - 'version': '1.1', + 'version': '1.2', 'category': 'Sales Management', 'depends': ['base', 'decimal_precision', 'mail', 'report'], 'demo': [ diff --git a/addons/product/product.py b/addons/product/product.py index 6b599f483a9..fac4a0693d8 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -342,9 +342,22 @@ class product_attribute_line(osv.osv): _columns = { 'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade'), 'attribute_id': fields.many2one('product.attribute', 'Attribute', required=True, ondelete='restrict'), - 'value_ids': fields.many2many('product.attribute.value', id1='line_id', id2='val_id', string='Product Attribute Value(s)'), + 'value_ids': fields.many2many('product.attribute.value', id1='line_id', id2='val_id', string='Attribute Values'), } + def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=100): + # TDE FIXME: currently overriding the domain; however as it includes a + # search on a m2o and one on a m2m, probably this will quickly become + # difficult to compute - check if performance optimization is required + if name and operator in ('=', 'ilike', '=ilike', 'like', '=like'): + new_args = ['|', ('attribute_id', operator, name), ('value_ids', operator, name)] + else: + new_args = args + return super(product_attribute_line, self).name_search( + cr, uid, name=name, + args=new_args, + operator=operator, context=context, limit=limit) + #---------------------------------------------------------- # Products @@ -473,6 +486,11 @@ class product_template(osv.osv): 'rental': fields.boolean('Can be Rent'), 'categ_id': fields.many2one('product.category','Internal Category', required=True, change_default=True, domain="[('type','=','normal')]" ,help="Select category for the current product"), 'price': fields.function(_product_template_price, fnct_inv=_set_product_template_price, type='float', string='Price', digits_compute=dp.get_precision('Product Price')), + 'currency_id': fields.related( + 'company_id', 'currency_id', + type='many2one', + relation='res.currency', + string='Currency'), 'list_price': fields.float('Sale Price', digits_compute=dp.get_precision('Product Price'), help="Base price to compute the customer price. Sometimes called the catalog price."), 'lst_price' : fields.related('list_price', type="float", string='Public Price', digits_compute=dp.get_precision('Product Price')), 'standard_price': fields.function(_compute_product_template_field, fnct_inv=_set_product_template_field, multi='_compute_product_template_field', type='float', string='Cost Price', digits_compute=dp.get_precision('Product Price'), @@ -596,8 +614,8 @@ class product_template(osv.osv): res = False return res - def onchange_type(self, cr, uid, ids, type): - return {} + def onchange_type(self, cr, uid, ids, type, context=None): + return {'value': {}} def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id): if uom_id: @@ -977,8 +995,8 @@ class product_product(osv.osv): self.pool.get('product.template').unlink(cr, uid, unlink_product_tmpl_ids, context=context) return res - def onchange_type(self, cr, uid, ids, type): - return {} + def onchange_type(self, cr, uid, ids, type, context=None): + return {'value': {}} def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id): if uom_id and uom_po_id: diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index 3d2c46def0d..144b501db4c 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -3,6 +3,30 @@ + + + product.attribute.value.view.tree + product.attribute.value + + + + + + + + + + + Variant Values + ir.actions.act_window + product.attribute.value + tree + form + + [('product_ids.product_tmpl_id', '=', active_id)] + {'default_product_tmpl_id': active_id} + + @@ -11,19 +35,13 @@ + - + - - - + - - - - - @@ -52,9 +70,15 @@ primary
- - +
+
+ +
@@ -69,75 +93,73 @@
- - - - - + + + + + + + + - - - + - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - + - + + - - + - - - - + + + + + + + +
@@ -154,43 +176,13 @@ primary - + + - - - - - - - - - - variants.template.tree - product.attribute.value - - - - - - - - - - - Variant Values - ir.actions.act_window - product.attribute.value - tree - form - - [('product_ids.product_tmpl_id', '=', active_id)] - {'default_product_tmpl_id': active_id} - - Product ir.actions.act_window @@ -294,31 +286,33 @@ Product Template - - + +
-
-

- Warning: adding or deleting attributes - will delete and recreate existing variants and lead - to the loss of their possible customizations. -

- + +

+ Warning: adding or deleting attributes + will delete and recreate existing variants and lead + to the loss of their possible customizations. +

@@ -381,7 +375,21 @@

- + + + Products + ir.actions.act_window + product.template + kanban,tree,form + form + {"search_default_products": 1, 'default_type': 'product'} + +

+ Click to define a new product. +

+
+
+
- + - - + + lst_price @@ -446,12 +455,12 @@ - - - - - - + + + + @@ -581,13 +590,13 @@
-
- - + + @@ -605,31 +614,6 @@
- - product.category.tree - product.category - child_id - - - - - - - - Products by Category - ir.actions.act_window - product.category - [('parent_id','=',False)] - tree - - -

- Here is a list of all your products classified by category. You - can click a category to get the list of all products linked to - this category or to a child of this category. -

-
-
Product Categories ir.actions.act_window @@ -643,22 +627,6 @@ id="menu_product_category_action_form" parent="prod_config_main" sequence="2"/> - - - Product Variants - ir.actions.act_window - product.product - form - tree,form,kanban - {'categ_id':active_id, 'search_default_categ_id':active_id} - - - - - Products by Categories - - - @@ -795,15 +763,17 @@ product.supplierinfo - - - - - - - - - + + + + + + + + + + +

The prices below will only be taken into account when your pricelist is set as based on vendor prices.

diff --git a/addons/product_email_template/views/product_view.xml b/addons/product_email_template/views/product_view.xml index 31cf5f5754e..5d7f17ab6ff 100644 --- a/addons/product_email_template/views/product_view.xml +++ b/addons/product_email_template/views/product_view.xml @@ -6,17 +6,21 @@ product.template - - + Miscellaneous + +
+ + /> - +
diff --git a/addons/product_expiry/product_expiry_view.xml b/addons/product_expiry/product_expiry_view.xml index ab89a5b0b78..ea33337a879 100644 --- a/addons/product_expiry/product_expiry_view.xml +++ b/addons/product_expiry/product_expiry_view.xml @@ -24,10 +24,10 @@ product.normal.form product.template - + - - + + diff --git a/addons/product_extended/product_extended_view.xml b/addons/product_extended/product_extended_view.xml index 27bd7443fe4..1428d2e7293 100644 --- a/addons/product_extended/product_extended_view.xml +++ b/addons/product_extended/product_extended_view.xml @@ -7,13 +7,14 @@ 3 - -
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 77c495c72d7..486b2431ee3 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -584,21 +584,7 @@ - - product.product.service.search - product.template - - - - - - - - - - - - + res.company.task.config res.company diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 8cc35ae7ca0..e11e5fea483 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -721,7 +721,8 @@
@@ -736,7 +737,8 @@
@@ -748,10 +750,9 @@ product.template - +
diff --git a/addons/report_intrastat/report_intrastat_view.xml b/addons/report_intrastat/report_intrastat_view.xml index 68087794633..2e33d6fb61b 100644 --- a/addons/report_intrastat/report_intrastat_view.xml +++ b/addons/report_intrastat/report_intrastat_view.xml @@ -30,7 +30,7 @@ product.template - + diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index bed6db4c422..78f01b19b4c 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -595,7 +595,8 @@
@@ -610,7 +611,8 @@
diff --git a/addons/sale_contract/views/product_template_view.xml b/addons/sale_contract/views/product_template_view.xml index 3a24fb3d458..9edde68a7d1 100644 --- a/addons/sale_contract/views/product_template_view.xml +++ b/addons/sale_contract/views/product_template_view.xml @@ -7,8 +7,8 @@ product.template - - + + diff --git a/addons/sale_service/views/sale_service_view.xml b/addons/sale_service/views/sale_service_view.xml index b67e266b7d6..856702f632f 100644 --- a/addons/sale_service/views/sale_service_view.xml +++ b/addons/sale_service/views/sale_service_view.xml @@ -16,11 +16,12 @@ product.template - - - - - + + Miscellaneous + + + +
@@ -49,7 +50,7 @@ product.template kanban,tree,form form - + {'search_default_services': 1,'default_auto_create_task':True,'default_sale_ok':True,'default_purchase_ok':False,'default_type':'service'} diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index bff005bf651..f8dd0055c42 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -56,6 +56,7 @@ Dashboard / Reports for Inventory Management will include: 'wizard/stock_return_picking_view.xml', 'wizard/make_procurement_view.xml', 'wizard/orderpoint_procurement_view.xml', + 'report/report_stock_forecast.xml', 'stock_incoterms.xml', 'stock_report.xml', 'stock_view.xml', @@ -70,7 +71,6 @@ Dashboard / Reports for Inventory Management will include: 'views/report_stockpicking_operations.xml', 'views/report_deliveryslip.xml', 'views/report_stockinventory.xml', - 'report/report_stock_forecast.xml', 'stock_dashboard.xml', 'wizard/stock_immediate_transfer.xml', 'wizard/stock_backorder_confirmation.xml', diff --git a/addons/stock/product.py b/addons/stock/product.py index 5958771200e..b38a7c56734 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -481,14 +481,7 @@ class product_template(osv.osv): result = mod_obj.xmlid_to_res_id(cr, uid, name, raise_if_not_found=True) result = act_obj.read(cr, uid, [result], context=context)[0] return result - - def action_open_quants(self, cr, uid, ids, context=None): - products = self._get_products(cr, uid, ids, context=context) - result = self._get_act_window_dict(cr, uid, 'stock.product_open_quants', context=context) - result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" - result['context'] = "{'search_default_locationgroup': 1, 'search_default_internal_loc': 1}" - return result - + def action_view_orderpoints(self, cr, uid, ids, context=None): products = self._get_products(cr, uid, ids, context=context) result = self._get_act_window_dict(cr, uid, 'stock.product_open_orderpoint', context=context) @@ -502,14 +495,9 @@ class product_template(osv.osv): def action_view_stock_moves(self, cr, uid, ids, context=None): products = self._get_products(cr, uid, ids, context=context) result = self._get_act_window_dict(cr, uid, 'stock.act_product_stock_move_open', context=context) - if len(ids) == 1 and len(products) == 1: - ctx = "{'tree_view_ref':'stock.view_move_tree', \ - 'default_product_id': %s, 'search_default_product_id': %s}" \ - % (products[0], products[0]) - result['context'] = ctx - else: - result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" - result['context'] = "{'tree_view_ref':'stock.view_move_tree'}" + if products: + result['context'] = "{'default_product_id': %d}" % products[0] + result['domain'] = "[('product_id.product_tmpl_id','in',[" + ','.join(map(str,ids)) + "])]" return result def write(self, cr, uid, ids, vals, context=None): diff --git a/addons/stock/product_view.xml b/addons/stock/product_view.xml index 6321f19c1be..5e5203b86a9 100644 --- a/addons/stock/product_view.xml +++ b/addons/stock/product_view.xml @@ -82,18 +82,15 @@ product.template - + + + + - - - - - - @@ -102,56 +99,27 @@ product.template - - - - - - - - - - - - - + + + + + + + + + - - {'default_groups_ref': ['base.group_user', 'base.group_sale_manager', 'stock.group_stock_manager']} + + + - - - - - - - - Product Template Kanban Stock product.template @@ -207,36 +175,74 @@ + + product.product.view.form.easy.inherit.stock + product.product + + + +
+
+
+
+
+ product.product.procurement product.product -
- - - -
+ +
+
+
+ + + +
+
@@ -245,31 +251,64 @@ product.template -
- - - + + + + +
+ +