diff --git a/mrp_average_cost/mrp.py b/mrp_average_cost/mrp.py index d3651c8..ac7f947 100644 --- a/mrp_average_cost/mrp.py +++ b/mrp_average_cost/mrp.py @@ -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 " diff --git a/mrp_average_cost/mrp_view.xml b/mrp_average_cost/mrp_view.xml index e48c56d..0e4b355 100644 --- a/mrp_average_cost/mrp_view.xml +++ b/mrp_average_cost/mrp_view.xml @@ -12,10 +12,10 @@ - - - - + + + + - + + @@ -46,7 +47,7 @@ - + @@ -66,7 +67,7 @@ - + @@ -83,7 +84,7 @@ - + @@ -97,7 +98,7 @@ - + diff --git a/product_usability/product.py b/product_usability/product.py index ce91ef8..fb15faa 100644 --- a/product_usability/product.py +++ b/product_usability/product.py @@ -16,6 +16,17 @@ class ProductTemplate(models.Model): purchase_ok = fields.Boolean(track_visibility='onchange') active = fields.Boolean(track_visibility='onchange') + def show_product_price_history(self): + self.ensure_one() + products = self.env['product.product'].search( + [('product_tmpl_id', '=', self._context['active_id'])]) + action = self.env['ir.actions.act_window'].for_xml_id( + 'product_usability', 'product_price_history_action') + action.update({ + 'domain': "[('id', 'in', %s)]" % products.ids, + }) + return action + class ProductProduct(models.Model): _inherit = 'product.product' @@ -38,9 +49,26 @@ class ProductProduct(models.Model): 'unique(default_code)', 'This internal reference already exists!')] + def show_product_price_history(self): + self.ensure_one() + action = self.env['ir.actions.act_window'].for_xml_id( + 'product_usability', 'product_price_history_action') + action.update({ + 'domain': "[('product_id', '=', %d)]" % self.ids[0], + }) + return action + class ProductSupplierinfo(models.Model): _inherit = 'product.supplierinfo' name = fields.Many2one( domain=[('supplier', '=', True), ('parent_id', '=', False)]) + + +class ProductPriceHistory(models.Model): + _inherit = 'product.price.history' + + company_currency_id = fields.Many2one( + related='company_id.currency_id', readonly=True, + string='Company Currency') diff --git a/product_usability/product_view.xml b/product_usability/product_view.xml index 30dd2ae..7079743 100644 --- a/product_usability/product_view.xml +++ b/product_usability/product_view.xml @@ -16,8 +16,9 @@ - + + @@ -30,8 +31,9 @@ - + + @@ -67,13 +69,9 @@ product.template - + + +