Skip to content

Commit

Permalink
Merge pull request #13 from ursais/11.0-log-message
Browse files Browse the repository at this point in the history
[IMP] Log message when a component is replaced
  • Loading branch information
max3903 authored Apr 20, 2018
2 parents 4d549f9 + e0b3644 commit 8942f20
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions ddmrp_production_equivalent/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Contributors
------------

* Antonio Yamuta <[email protected]>
* Maxime Chambreuil <[email protected]>

Funders
-------
Expand Down
4 changes: 2 additions & 2 deletions ddmrp_production_equivalent/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
{
"name": "MRP BoM Equivalences when Production Order is Created",
"summary": "Use equivalences of a part when appropriate",
"version": "11.0.1.0.0",
"version": "11.0.1.0.1",
"license": "AGPL-3",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"category": "MRP",
"website": "http://www.opensourceintegrators.com",
"website": "https://github.com/OCA/ddmrp",
"depends": [
"ddmrp",
"mrp",
Expand Down
11 changes: 8 additions & 3 deletions ddmrp_production_equivalent/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models
from odoo import models, _


class MrpProduction(models.Model):
Expand All @@ -15,8 +15,9 @@ def _get_product_equivalent(self, bom_line, requested_qty):
p_obj = self.env['product.product']
products = p_obj.search(self._get_product_search_criteria(bom_line),
order='priority asc, id asc')
# exclude the non-equivalent parts listed in the BOM line
products -= bom_line.nonequivalent_product_ids
# exclude the non-equivalent parts listed in the BOM line and the
# current product
products -= bom_line.nonequivalent_product_ids + bom_line.product_id
product = False
for product in products:
if product.orderpoint_ids and \
Expand All @@ -36,8 +37,12 @@ def _generate_raw_move(self, bom_line, line_data):
product_equivalent = self._get_product_equivalent(bom_line,
line_data['qty'])
if product_equivalent:
body = _('%s has been replaced by %s.' %
(sm.product_id.name_get()[0][1],
product_equivalent.name_get()[0][1]))
sm.write({
'price_unit': product_equivalent.standard_price,
'product_id': product_equivalent.id,
})
self.message_post(body=body)
return sm

0 comments on commit 8942f20

Please sign in to comment.