Skip to content

Commit

Permalink
Several small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-via committed Jun 4, 2019
1 parent a848181 commit ce4fac8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
18 changes: 8 additions & 10 deletions mrp_average_cost/mrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ def _compute_total_labour_cost(self):

@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
Expand Down Expand Up @@ -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
Expand All @@ -188,7 +186,7 @@ def compute_order_unit_cost(self, cr, uid, order, context=None):
# 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
Expand All @@ -208,15 +206,15 @@ def compute_order_unit_cost(self, cr, uid, order, context=None):
_('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'
labor_cost_per_unit = bom.total_labour_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
# 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'
Expand All @@ -235,11 +233,11 @@ def compute_order_unit_cost(self, cr, uid, order, context=None):
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
Expand Down
5 changes: 2 additions & 3 deletions sale_usability/account_invoice.py
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down Expand Up @@ -36,7 +35,7 @@ def py3o_lines_layout_groupby_order(self, subtotal=True):
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})
Expand Down

0 comments on commit ce4fac8

Please sign in to comment.