mrp_average_cost: Fix decimal precision

product_usability: add link to show history of standard price
This commit is contained in:
Alexis de Lattre
2017-05-22 20:57:33 +02:00
parent 08445ad370
commit b8255a5287
4 changed files with 56 additions and 34 deletions

View File

@@ -18,9 +18,8 @@ class LabourCostProfile(models.Model):
name = fields.Char(
string='Name', required=True, track_visibility='onchange')
hour_cost = fields.Monetary(
hour_cost = fields.Float(
string='Cost per Hour', required=True,
currency_field='company_currency_id',
digits=dp.get_precision('Product Price'),
track_visibility='onchange',
help="Labour cost per hour per person in company currency")
@@ -54,9 +53,9 @@ class MrpBomLabourLine(models.Model):
"items of the BOM, in hours.")
labour_cost_profile_id = fields.Many2one(
'labour.cost.profile', string='Labour Cost Profile', required=True)
labour_cost_subtotal = fields.Monetary(
labour_cost_subtotal = fields.Float(
compute='_compute_labour_cost_subtotal', readonly=True, store=True,
string='Subtotal', currency_field='company_currency_id')
digits=dp.get_precision('Product Price'), string='Subtotal')
company_currency_id = fields.Many2one(
related='bom_id.company_id.currency_id', readonly=True,
string='Company Currency')
@@ -107,28 +106,24 @@ class MrpBom(models.Model):
company_currency_id = fields.Many2one(
related='company_id.currency_id', readonly=True,
string='Company Currency')
total_labour_cost = fields.Monetary(
total_labour_cost = fields.Float(
compute='_compute_total_labour_cost', readonly=True,
currency_field='company_currency_id',
digits=dp.get_precision('Product Price'),
string="Total Labour Cost")
extra_cost = fields.Monetary(
extra_cost = fields.Float(
string='Extra Cost', track_visibility='onchange',
digits=dp.get_precision('Product Price'),
currency_field='company_currency_id',
help="Extra cost for the production of the quantity of "
"items of the BOM, in company currency. "
"You can use this field to enter the cost of the consumables "
"that are used to produce the product but are not listed in "
"the BOM")
total_components_cost = fields.Monetary(
total_components_cost = fields.Float(
compute='_compute_total_cost', readonly=True,
currency_field='company_currency_id',
digits=dp.get_precision('Product Price'),
string='Total Components Cost')
total_cost = fields.Float(
compute='_compute_total_cost', readonly=True,
currency_field='company_currency_id', string='Total Cost',
compute='_compute_total_cost', readonly=True, string='Total Cost',
digits=dp.get_precision('Product Price'),
help="Total Cost = Total Components Cost + "
"Total Labour Cost + Extra Cost")
@@ -170,16 +165,16 @@ class MrpBomLine(models.Model):
standard_price = fields.Float(
related='product_id.standard_price', readonly=True)
# Monetary ? standard_price on product is a float...
# company_currency_id =
company_currency_id = fields.Many2one(
related='bom_id.company_id.currency_id', readonly=True,
string='Company Currency')
class MrpProduction(models.Model):
_inherit = 'mrp.production'
unit_cost = fields.Monetary(
unit_cost = fields.Float(
string='Unit Cost', readonly=True,
currency_field='company_currency_id',
digits=dp.get_precision('Product Price'),
help="This cost per unit in the unit of measure of the product "
"in company currency takes into account "

View File

@@ -12,10 +12,10 @@
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<field name="routing_id" position="after">
<field name="total_components_cost"/>
<field name="total_labour_cost"/>
<field name="extra_cost"/>
<label for="total_cost"/>
<field name="total_components_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="total_labour_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="extra_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<label for="total_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<div>
<field name="total_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"
@@ -33,7 +33,8 @@
</page>
</xpath>
<xpath expr="//field[@name='bom_line_ids']/tree/field[@name='product_uom_id']" position="after">
<field name="standard_price"/>
<field name="standard_price" widget="monetary" options="{'currency_field': 'company_currency_id'}" sum="Total"/>
<field name="company_currency_id" invisible="1"/>
</xpath>
</field>
</record>
@@ -46,7 +47,7 @@
<field name="bom_id" invisible="not context.get('mrp_bom_labour_line_main_view')"/>
<field name="labour_time" string="Labour Time (hours)"/>
<field name="labour_cost_profile_id"/>
<field name="labour_cost_subtotal" sum="Total"/>
<field name="labour_cost_subtotal" sum="Total" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="company_currency_id" invisible="1"/>
<field name="note"/>
</tree>
@@ -66,7 +67,7 @@
<label string="hours"/>
</div>
<field name="labour_cost_profile_id"/>
<field name="labour_cost_subtotal"/>
<field name="labour_cost_subtotal" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="company_currency_id" invisible="1"/>
<field name="note"/>
</group>
@@ -83,7 +84,7 @@
<form string="Labour Cost Profile">
<group name="main">
<field name="name"/>
<field name="hour_cost"/>
<field name="hour_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="company_currency_id" invisible="1"/>
</group>
@@ -97,7 +98,7 @@
<field name="arch" type="xml">
<tree string="Labour Cost Profiles">
<field name="name"/>
<field name="hour_cost"/>
<field name="hour_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="company_currency_id" invisible="1"/>
</tree>
</field>