Merge branch '12.0' of github.com:akretion/odoo-usability into 12.0

This commit is contained in:
Alexis de Lattre
2019-07-09 17:41:14 +02:00
3 changed files with 11 additions and 14 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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 <alexis.delattre@akretion.com>
# 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})