Several small fixes
This commit is contained in:
@@ -45,14 +45,12 @@ class MrpBom(models.Model):
|
|||||||
|
|
||||||
@api.depends('bom_line_ids.product_id.standard_price', 'total_labour_cost', 'extra_cost')
|
@api.depends('bom_line_ids.product_id.standard_price', 'total_labour_cost', 'extra_cost')
|
||||||
def _compute_total_cost(self):
|
def _compute_total_cost(self):
|
||||||
puo = self.pool['product.uom']
|
|
||||||
for bom in self:
|
for bom in self:
|
||||||
component_cost = 0.0
|
component_cost = 0.0
|
||||||
for line in bom.bom_line_ids:
|
for line in bom.bom_line_ids:
|
||||||
component_price = line.product_id.standard_price
|
component_price = line.product_id.standard_price
|
||||||
component_qty_product_uom = puo._compute_qty_obj(
|
component_qty_product_uom = line.product_uom_id._compute_quantity(
|
||||||
cr, uid, line.product_uom, line.product_qty,
|
line.product_qty, line.product_id.uom_id)
|
||||||
line.product_id.uom_id, context=context) # TODO
|
|
||||||
component_cost += component_price * component_qty_product_uom
|
component_cost += component_price * component_qty_product_uom
|
||||||
total_cost = component_cost + bom.extra_cost + bom.total_labour_cost
|
total_cost = component_cost + bom.extra_cost + bom.total_labour_cost
|
||||||
bom.total_components_cost = component_cost
|
bom.total_components_cost = component_cost
|
||||||
@@ -173,7 +171,7 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
# TODO port to v12
|
# TODO port to v12
|
||||||
def compute_order_unit_cost(self, cr, uid, order, context=None):
|
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
|
mo_total_price = 0.0 # In the UoM of the M0
|
||||||
labor_cost_per_unit = 0.0 # In the UoM of the product
|
labor_cost_per_unit = 0.0 # In the UoM of the product
|
||||||
extra_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
|
# materials (consumed or not), so it gives a good price
|
||||||
# per unit at the end
|
# per unit at the end
|
||||||
raw_price = raw_smove.product_id.standard_price
|
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,
|
cr, uid, raw_smove.product_uom, raw_smove.product_qty,
|
||||||
raw_smove.product_id.uom_id, context=context)
|
raw_smove.product_id.uom_id, context=context)
|
||||||
raw_material_cost = raw_price * raw_qty_product_uom
|
raw_material_cost = raw_price * raw_qty_product_uom
|
||||||
@@ -208,7 +206,7 @@ class MrpProduction(models.Model):
|
|||||||
_('Error:'),
|
_('Error:'),
|
||||||
_("Missing Product Quantity on bill of material '%s'.")
|
_("Missing Product Quantity on bill of material '%s'.")
|
||||||
% bom.name)
|
% 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,
|
cr, uid, bom.product_uom, bom.product_qty,
|
||||||
bom.product_id.uom_id, context=context)
|
bom.product_id.uom_id, context=context)
|
||||||
assert bom_qty_product_uom > 0, 'BoM qty should be positive'
|
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
|
extra_cost_per_unit = bom.extra_cost / bom_qty_product_uom
|
||||||
# mo_standard_price and labor_cost_per_unit are
|
# mo_standard_price and labor_cost_per_unit are
|
||||||
# in the UoM of the product (not of the MO/BOM)
|
# 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,
|
cr, uid, order.product_uom, order.product_qty,
|
||||||
order.product_id.uom_id, context=context)
|
order.product_id.uom_id, context=context)
|
||||||
assert mo_qty_product_uom > 0, 'MO qty should be positive'
|
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):
|
def update_standard_price(self, cr, uid, order, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
puo = self.pool['product.uom']
|
uuo = self.pool['uom.uom']
|
||||||
product = order.product_id
|
product = order.product_id
|
||||||
mo_standard_price = self.compute_order_unit_cost(
|
mo_standard_price = self.compute_order_unit_cost(
|
||||||
cr, uid, order, context=context)
|
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,
|
cr, uid, order.product_uom, order.product_qty,
|
||||||
order.product_id.uom_id, context=context)
|
order.product_id.uom_id, context=context)
|
||||||
# I can't use the native method _update_average_price of stock.move
|
# I can't use the native method _update_average_price of stock.move
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright (C) 2015-2019 Akretion (http://www.akretion.com)
|
||||||
# Copyright (C) 2015-2018 Akretion (http://www.akretion.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# 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']:
|
for line in res1.values()[0]['lines']:
|
||||||
res2.append({'line': line})
|
res2.append({'line': line})
|
||||||
else:
|
else:
|
||||||
for order, ldict in res1.iteritems():
|
for order, ldict in res1.items():
|
||||||
res2.append({'categ': order})
|
res2.append({'categ': order})
|
||||||
for line in ldict['lines']:
|
for line in ldict['lines']:
|
||||||
res2.append({'line': line})
|
res2.append({'line': line})
|
||||||
|
|||||||
Reference in New Issue
Block a user