From 24bca8fd4ae3ea1307c80e2262c4e5493520e228 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Fri, 2 Aug 2019 14:02:31 +0000 Subject: [PATCH] [REF] stock_landed_costs: landed cost special product We remove the special views/actions/menuitems for the "landed cost type" product. The user should now chose the split method on the landed costs directly. We still keep the landed_cost_ok field that will be used in the next commit integrating the landed costs with the vendor bill. task-59011 --- addons/stock_landed_costs/models/product.py | 16 +-- .../models/stock_landed_cost.py | 14 ++- addons/stock_landed_costs/tests/common.py | 1 - .../tests/test_stockvaluationlayer.py | 1 - .../views/product_views.xml | 18 ++-- .../views/res_config_settings_views.xml | 1 - .../views/stock_landed_cost_views.xml | 97 +------------------ 7 files changed, 21 insertions(+), 127 deletions(-) diff --git a/addons/stock_landed_costs/models/product.py b/addons/stock_landed_costs/models/product.py index 47719e4fe04..f3892c362b6 100644 --- a/addons/stock_landed_costs/models/product.py +++ b/addons/stock_landed_costs/models/product.py @@ -3,23 +3,9 @@ from odoo import fields, models -SPLIT_METHOD = [ - ('equal', 'Equal'), - ('by_quantity', 'By Quantity'), - ('by_current_cost_price', 'By Current Cost'), - ('by_weight', 'By Weight'), - ('by_volume', 'By Volume'), -] - class ProductTemplate(models.Model): _inherit = "product.template" landed_cost_ok = fields.Boolean('Is a Landed Cost', help='Indicates whether the product is a landed cost.') - split_method = fields.Selection( - selection=SPLIT_METHOD, string='Split Method', default='equal', - help="Equal : Cost will be equally divided.\n" - "By Quantity : Cost will be divided according to product's quantity.\n" - "By Current cost : Cost will be divided according to product's current cost.\n" - "By Weight : Cost will be divided depending on its weight.\n" - "By Volume : Cost will be divided depending on its volume.") + diff --git a/addons/stock_landed_costs/models/stock_landed_cost.py b/addons/stock_landed_costs/models/stock_landed_cost.py index 1aa6451d0de..a516da51338 100644 --- a/addons/stock_landed_costs/models/stock_landed_cost.py +++ b/addons/stock_landed_costs/models/stock_landed_cost.py @@ -4,11 +4,19 @@ from collections import defaultdict from odoo import api, fields, models, tools, _ -from odoo.addons.stock_landed_costs.models import product from odoo.exceptions import UserError from odoo.tools.float_utils import float_is_zero +SPLIT_METHOD = [ + ('equal', 'Equal'), + ('by_quantity', 'By Quantity'), + ('by_current_cost_price', 'By Current Cost'), + ('by_weight', 'By Weight'), + ('by_volume', 'By Volume'), +] + + class LandedCost(models.Model): _name = 'stock.landed.cost' _description = 'Stock Landed Cost' @@ -267,7 +275,7 @@ class LandedCostLine(models.Model): required=True, ondelete='cascade') product_id = fields.Many2one('product.product', 'Product', required=True) price_unit = fields.Float('Cost', digits='Product Price', required=True) - split_method = fields.Selection(product.SPLIT_METHOD, string='Split Method', required=True) + split_method = fields.Selection(SPLIT_METHOD, string='Split Method', required=True) account_id = fields.Many2one('account.account', 'Account', domain=[('deprecated', '=', False)]) @api.onchange('product_id') @@ -275,7 +283,7 @@ class LandedCostLine(models.Model): if not self.product_id: self.quantity = 0.0 self.name = self.product_id.name or '' - self.split_method = self.product_id.split_method or 'equal' + self.split_method = 'equal' self.price_unit = self.product_id.standard_price or 0.0 self.account_id = self.product_id.property_account_expense_id.id or self.product_id.categ_id.property_account_expense_categ_id.id diff --git a/addons/stock_landed_costs/tests/common.py b/addons/stock_landed_costs/tests/common.py index 4f30966a930..5c9fb50676e 100644 --- a/addons/stock_landed_costs/tests/common.py +++ b/addons/stock_landed_costs/tests/common.py @@ -71,5 +71,4 @@ class TestStockLandedCostsCommon(AccountingTestCase): def _create_services(self, name): return self.Product.create({ 'name': name, - 'landed_cost_ok': True, 'type': 'service'}) diff --git a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py index b5a70715790..db4525b8af8 100644 --- a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py +++ b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py @@ -14,7 +14,6 @@ class TestStockValuationLC(TestStockValuationCommon): cls.productlc1 = cls.env['product.product'].create({ 'name': 'product1', 'type': 'service', - 'landed_cost_ok': True, 'categ_id': cls.env.ref('product.product_category_all').id, }) diff --git a/addons/stock_landed_costs/views/product_views.xml b/addons/stock_landed_costs/views/product_views.xml index c52baf03822..f5d768ed1e8 100644 --- a/addons/stock_landed_costs/views/product_views.xml +++ b/addons/stock_landed_costs/views/product_views.xml @@ -4,19 +4,15 @@ product.template.landed.cost.form product.template - + - - - - - -
-
- -
+ diff --git a/addons/stock_landed_costs/views/res_config_settings_views.xml b/addons/stock_landed_costs/views/res_config_settings_views.xml index c72c0249461..6b591823881 100644 --- a/addons/stock_landed_costs/views/res_config_settings_views.xml +++ b/addons/stock_landed_costs/views/res_config_settings_views.xml @@ -11,7 +11,6 @@
diff --git a/addons/stock_landed_costs/views/stock_landed_cost_views.xml b/addons/stock_landed_costs/views/stock_landed_cost_views.xml index 97c6a5f8861..562dce04989 100644 --- a/addons/stock_landed_costs/views/stock_landed_cost_views.xml +++ b/addons/stock_landed_costs/views/stock_landed_cost_views.xml @@ -44,7 +44,7 @@ + context="{'default_landed_cost_ok': True}"/> @@ -57,8 +57,7 @@ + context="{'default_landed_cost_ok': True, 'default_type': 'service'}"/> @@ -193,97 +192,5 @@
- - - - stock.landed.cost.type.form - product.product - 25 - -
- - - -
-
-
-

- -

-
- - - - - - - - - - - - - - - - - -
-
- - -
-
-
-
- - - product.product.tree - product.product - - - - - - - - - - - Landed Cost Types - ir.actions.act_window - product.product - [('landed_cost_ok','=',True)] - tree,form - {'default_landed_cost_ok': True, 'default_type': 'service'} - - -

- Define a new kind of landed cost -

-
-
- - - - tree - - - - - - - form - - - - - -