diff options
| author | Simon Lejeune <sle@openerp.com> | 2019-08-02 14:02:31 +0000 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2019-08-07 14:11:21 +0000 |
| commit | 24bca8fd4ae3ea1307c80e2262c4e5493520e228 (patch) | |
| tree | dc92d179847e89b8169b81f15191e73a50cf34d2 /addons | |
| parent | 98f974cae305f868de97682db8b36e5c570d9e70 (diff) | |
[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
Diffstat (limited to 'addons')
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 @@ <record id="view_product_landed_cost_form" model="ir.ui.view"> <field name="name">product.template.landed.cost.form</field> <field name="model">product.template</field> - <field name="inherit_id" ref="purchase.view_product_supplier_inherit"/> + <field name="inherit_id" ref="account.product_template_form_view"/> <field name="arch" type="xml"> - <xpath expr="//group[@name='inventory']" position="inside"> - <group string="Inventory Valuation" name="inventory_valuation" invisible="1"> - <field name="split_method" invisible="1"/> - </group> - </xpath> - <div name="options" position="inside"> - <div attrs="{'invisible':[('type', 'not in', ['product', 'consu', 'service'])]}"> - <field name="landed_cost_ok"/> - <label for="landed_cost_ok"/> + <page name="invoicing" position="inside"> + <div attrs="{'invisible':[('type', '!=', 'service')]}"> + <group string="Landed Costs" name="landedcosts"> + <field name="landed_cost_ok"/> + </group> </div> - </div> + </page> </field> </record> </data> 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 @@ <div class="mt16"> <label for="lc_journal_id" string="Default Journal"/> <field name="lc_journal_id"/> - <button name="%(stock_landed_costs.stock_landed_cost_type_action)d" icon="fa-arrow-right" type="action" string="Landed Cost Types" class="btn-link"/> </div> </div> </div> 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 @@ <group> <field name="product_id" domain="[('landed_cost_ok', '=', True)]" - context="{'default_landed_cost_ok': True, 'form_view_ref':'stock_landed_costs.view_stock_landed_cost_type_form'}"/> + context="{'default_landed_cost_ok': True}"/> <field name="price_unit"/> </group> <group> @@ -57,8 +57,7 @@ </form> <tree string="Cost Lines" editable="bottom"> <field name="product_id" - domain="[('landed_cost_ok', '=', True)]" - context="{'default_landed_cost_ok': True, 'default_type': 'service', 'form_view_ref':'stock_landed_costs.view_stock_landed_cost_type_form'}"/> + context="{'default_landed_cost_ok': True, 'default_type': 'service'}"/> <field name="name"/> <field name="account_id" options="{'no_create': True}"/> <field name="split_method"/> @@ -193,97 +192,5 @@ </record> <menuitem action="action_stock_landed_cost" name="Landed Costs" parent="stock.menu_stock_warehouse_mgmt" id="menu_stock_landed_cost" sequence="115"/> - - <!-- STOCK.LANDED.COST.TYPE --> - <record id="view_stock_landed_cost_type_form" model="ir.ui.view"> - <field name="name">stock.landed.cost.type.form</field> - <field name="model">product.product</field> - <field name="priority">25</field> - <field name="arch" type="xml"> - <form string="Landed Costs"> - <sheet> - <widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/> - <field name="image_1920" widget="image" class="oe_avatar" options="{'image_preview': 'image_128'}"/> - <div class="oe_title"> - <div class="oe_edit_only"> - <label for="name" name='label_name' string="Product Name"/> - </div> - <h1> - <field name="name"/> - </h1> - <label for="categ_id" class="oe_edit_only"/> - <h2> - <field name="categ_id"/> - </h2> - </div> - <notebook> - <page string="Information"> - <group> - <group> - <field name="split_method"/> - <field name="active" invisible="1"/> - <field name="standard_price"/> - <field name="property_account_expense_id" domain="[('internal_type','=','other'),('deprecated', '=', False)]"/> - </group> - <group> - <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/> - <field name="type"/> - </group> - </group> - <field name="description" placeholder="describe the product characteristics..."/> - </page> - </notebook> - </sheet> - <div class="oe_chatter"> - <field name="message_follower_ids" widget="mail_followers"/> - <field name="message_ids" widget="mail_thread"/> - </div> - </form> - </field> - </record> - - <record id="stock_landed_cost_tree_view" model="ir.ui.view"> - <field name="name">product.product.tree</field> - <field name="model">product.product</field> - <field name="arch" type="xml"> - <tree string="Products"> - <field name="name" string="Landed Cost Type"/> - <field name="split_method"/> - <field name="standard_price"/> - </tree> - </field> - </record> - - <record id="stock_landed_cost_type_action" model="ir.actions.act_window"> - <field name="name">Landed Cost Types</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">product.product</field> - <field name="domain">[('landed_cost_ok','=',True)]</field> - <field name="view_mode">tree,form</field> - <field name="context">{'default_landed_cost_ok': True, 'default_type': 'service'}</field> - <field name="search_view_id" ref="product.product_search_form_view"/> - <field name="help" type="html"> - <p class="o_view_nocontent_smiling_face"> - Define a new kind of landed cost - </p> - </field> - </record> - - <record id="stock_landed_cost_type_action1" model="ir.actions.act_window.view"> - <field eval="1" name="sequence"/> - <field name="view_mode">tree</field> - <field name="view_id" ref="stock_landed_cost_tree_view"/> - <field name="act_window_id" ref="stock_landed_cost_type_action"/> - </record> - - <record id="stock_landed_cost_type_action2" model="ir.actions.act_window.view"> - <field eval="2" name="sequence"/> - <field name="view_mode">form</field> - <field name="view_id" ref="view_stock_landed_cost_type_form"/> - <field name="act_window_id" ref="stock_landed_cost_type_action"/> - </record> - - <menuitem action="stock_landed_cost_type_action" name="Landed Cost Types" parent="stock.menu_product_in_config_stock" id="menu_stock_landed_cost_type" sequence="3"/> - </data> </odoo> |
