diff options
| author | Goffin Simon <sig@odoo.com> | 2017-05-18 09:55:41 +0200 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2017-06-07 14:35:37 +0200 |
| commit | 2332df6bc7380e742e7d3dfb945124e21078087d (patch) | |
| tree | 415f8c436f80fbabe1b7d05f9a45591281ccc2ac | |
| parent | 7b210167604d4450d0b52dfddd39ca3ccc672564 (diff) | |
[FIX] mrp: Post inventory button without finished product
Let's consider P1, P2 and P3 with a cost=1$, three stockable products where
P1 and P2 are in the same product category PC1 with a Stock valuation
account = SVA1 and P3 is in the product category PC2 with a Stock valuation
accout = SVA2. PC1 and PC2 are set with costing method in real price and
Inventory valuation = perpetual(automated).
Steps to reproduce this issue:
-Create a BOM where P3 is composed by 1 P1 and 1 P2
-Create a PO for P1 and P2 with a cost of 5$ for each one
-Create a MO to produce 1 P3
-Check availability
-Insert manually the consumed product(1 P1 and 1 P2)
-The button "Post Inventory" appeared, clicked on it
-Check the general ledger, two moves with debit=5$ has been created
for P1 and P2 in PC1(it's ok)
-Produce the MO and click on "Post Inventory" again
-Check the general ledger, two moves have been created, one with a credit of 2$
on PC1 and one of debit of 2$ on PC2(it was wrong)
The expected moves for the last step is:
a credit of 10$ on PC1 and a debit of 10$ on PC2 because the purchase price must be
considered as P1 and P2 are in real price.
NB: Everything is ok if the button "Post Inventory" is clicked after the production.
opw:741748
| -rw-r--r-- | addons/mrp/models/mrp_production.py | 7 | ||||
| -rw-r--r-- | addons/stock/models/product.py | 3 | ||||
| -rw-r--r-- | addons/stock_account/models/product.py | 3 |
3 files changed, 11 insertions, 2 deletions
diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 8b0b7c48dea..097876b0b6b 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -208,8 +208,11 @@ class MrpProduction(models.Model): @api.depends('move_raw_ids.quantity_done', 'move_finished_ids.quantity_done') def _compute_post_visible(self): for order in self: - order.post_visible = any(order.move_raw_ids.filtered(lambda x: (x.quantity_done) > 0 and (x.state not in ['done', 'cancel']))) or \ - any(order.move_finished_ids.filtered(lambda x: (x.quantity_done) > 0 and (x.state not in ['done', 'cancel']))) + if order.product_tmpl_id._is_cost_method_standard(): + order.post_visible = any((x.quantity_done > 0 and x.state not in ['done', 'cancel']) for x in order.move_raw_ids) or \ + any((x.quantity_done > 0 and x.state not in ['done' 'cancel']) for x in order.move_finished_ids) + else: + order.post_visible = any((x.quantity_done > 0 and x.state not in ['done' 'cancel']) for x in order.move_finished_ids) @api.multi @api.depends('workorder_ids.state', 'move_finished_ids') diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index b48d4f8570d..5a71c1fccf1 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -416,6 +416,9 @@ class ProductTemplate(models.Model): relation="stock.location.route", string="Category Routes", related='categ_id.total_route_ids') + def _is_cost_method_standard(self): + return True + def _compute_quantities(self): res = self._compute_quantities_dict() for template in self: diff --git a/addons/stock_account/models/product.py b/addons/stock_account/models/product.py index 1e4ac7ffbe1..1b15d2aa066 100644 --- a/addons/stock_account/models/product.py +++ b/addons/stock_account/models/product.py @@ -51,6 +51,9 @@ class ProductTemplate(models.Model): def _compute_cost_method(self): self.cost_method = self.property_cost_method or self.categ_id.property_cost_method + def _is_cost_method_standard(self): + return self.property_cost_method == 'standard' + @api.one def _set_cost_method(self): return self.write({'property_cost_method': self.cost_method}) |
