From ce4fac8a10fe51622ce427127bd82407ded6a789 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 4 Jun 2019 17:24:16 +0200 Subject: [PATCH 1/2] Several small fixes --- mrp_average_cost/mrp.py | 18 ++++++++---------- sale_usability/account_invoice.py | 5 ++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/mrp_average_cost/mrp.py b/mrp_average_cost/mrp.py index 0810949..6c30476 100644 --- a/mrp_average_cost/mrp.py +++ b/mrp_average_cost/mrp.py @@ -45,14 +45,12 @@ class MrpBom(models.Model): @api.depends('bom_line_ids.product_id.standard_price', 'total_labour_cost', 'extra_cost') def _compute_total_cost(self): - puo = self.pool['product.uom'] for bom in self: component_cost = 0.0 for line in bom.bom_line_ids: component_price = line.product_id.standard_price - component_qty_product_uom = puo._compute_qty_obj( - cr, uid, line.product_uom, line.product_qty, - line.product_id.uom_id, context=context) # TODO + component_qty_product_uom = line.product_uom_id._compute_quantity( + line.product_qty, line.product_id.uom_id) component_cost += component_price * component_qty_product_uom total_cost = component_cost + bom.extra_cost + bom.total_labour_cost bom.total_components_cost = component_cost @@ -173,7 +171,7 @@ class MrpProduction(models.Model): # TODO port to v12 def compute_order_unit_cost(self, cr, uid, order, context=None): - puo = self.pool['product.uom'] + uuo = self.pool['uom.uom'] mo_total_price = 0.0 # In the UoM of the M0 labor_cost_per_unit = 0.0 # In the UoM of the product extra_cost_per_unit = 0.0 # In the UoM of the product @@ -188,7 +186,7 @@ class MrpProduction(models.Model): # materials (consumed or not), so it gives a good price # per unit at the end raw_price = raw_smove.product_id.standard_price - raw_qty_product_uom = puo._compute_qty_obj( + raw_qty_product_uom = uuo._compute_qty_obj( cr, uid, raw_smove.product_uom, raw_smove.product_qty, raw_smove.product_id.uom_id, context=context) raw_material_cost = raw_price * raw_qty_product_uom @@ -208,7 +206,7 @@ class MrpProduction(models.Model): _('Error:'), _("Missing Product Quantity on bill of material '%s'.") % bom.name) - bom_qty_product_uom = puo._compute_qty_obj( + bom_qty_product_uom = uuo._compute_qty_obj( cr, uid, bom.product_uom, bom.product_qty, bom.product_id.uom_id, context=context) assert bom_qty_product_uom > 0, 'BoM qty should be positive' @@ -216,7 +214,7 @@ class MrpProduction(models.Model): extra_cost_per_unit = bom.extra_cost / bom_qty_product_uom # mo_standard_price and labor_cost_per_unit are # in the UoM of the product (not of the MO/BOM) - mo_qty_product_uom = puo._compute_qty_obj( + mo_qty_product_uom = uuo._compute_qty_obj( cr, uid, order.product_uom, order.product_qty, order.product_id.uom_id, context=context) assert mo_qty_product_uom > 0, 'MO qty should be positive' @@ -235,11 +233,11 @@ class MrpProduction(models.Model): def update_standard_price(self, cr, uid, order, context=None): if context is None: context = {} - puo = self.pool['product.uom'] + uuo = self.pool['uom.uom'] product = order.product_id mo_standard_price = self.compute_order_unit_cost( cr, uid, order, context=context) - mo_qty_product_uom = puo._compute_qty_obj( + mo_qty_product_uom = uuo._compute_qty_obj( cr, uid, order.product_uom, order.product_qty, order.product_id.uom_id, context=context) # I can't use the native method _update_average_price of stock.move diff --git a/sale_usability/account_invoice.py b/sale_usability/account_invoice.py index 8b8316c..b12282d 100644 --- a/sale_usability/account_invoice.py +++ b/sale_usability/account_invoice.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2015-2018 Akretion (http://www.akretion.com) +# Copyright (C) 2015-2019 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -36,7 +35,7 @@ class AccountInvoice(models.Model): for line in res1.values()[0]['lines']: res2.append({'line': line}) else: - for order, ldict in res1.iteritems(): + for order, ldict in res1.items(): res2.append({'categ': order}) for line in ldict['lines']: res2.append({'line': line}) From 475993422ed4f806edd63b8bf3d1dab15fe9a10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Wed, 19 Jun 2019 12:44:57 -0300 Subject: [PATCH 2/2] fix price history link bug #96 --- product_usability/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product_usability/product.py b/product_usability/product.py index dfa1e13..5a95211 100644 --- a/product_usability/product.py +++ b/product_usability/product.py @@ -22,7 +22,7 @@ class ProductTemplate(models.Model): action = self.env['ir.actions.act_window'].for_xml_id( 'product_usability', 'product_price_history_action') action.update({ - 'domain': "[('id', 'in', %s)]" % products.ids, + 'domain': "[('product_id', 'in', %s)]" % products.ids, }) return action