[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
This commit is contained in:
Simon Lejeune
2019-08-07 14:11:21 +00:00
parent 98f974cae3
commit 24bca8fd4a
7 changed files with 21 additions and 127 deletions
+1 -15
View File
@@ -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.")
@@ -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
@@ -71,5 +71,4 @@ class TestStockLandedCostsCommon(AccountingTestCase):
def _create_services(self, name):
return self.Product.create({
'name': name,
'landed_cost_ok': True,
'type': 'service'})
@@ -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,
})
@@ -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>
@@ -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>
@@ -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>