[12.0][MIG] mrp_bom_comparison

This commit is contained in:
Adrià Gil Sorribes
2021-05-27 15:06:48 +02:00
parent 14f2912f05
commit 1153b6a850
8 changed files with 53 additions and 53 deletions

View File

@@ -14,13 +14,13 @@ Bill of Materials comparison
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/10.0/mrp_bom_comparison
:target: https://github.com/OCA/manufacture/tree/12.0/mrp_bom_comparison
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-10-0/manufacture-10-0-mrp_bom_comparison
:target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_bom_comparison
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/10.0
:target: https://runbot.odoo-community.org/runbot/129/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -58,7 +58,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_comparison%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_comparison%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -88,6 +88,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/10.0/mrp_bom_comparison>`_ project on GitHub.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/12.0/mrp_bom_comparison>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,7 +4,7 @@
{
"name": "Bill of Materials comparison",
"summary": "Compare two Bill of Materials to view the differences",
"version": "10.0.1.0.0",
"version": "12.0.1.0.0",
"category": "Manufacturing",
"website": "https://github.com/OCA/manufacture",
"author": "ABF OSIELL, Odoo Community Association (OCA)",
@@ -13,11 +13,10 @@
"installable": True,
"depends": [
"mrp",
"report",
],
"data": [
"wizards/mrp_bom_comparison.xml",
"reports/mrp_bom_comparison.xml",
"reports.xml",
"views/reports.xml",
],
}

View File

@@ -1 +1,2 @@
* Sébastien Alix <sebastien.alix@osiell.com> (https://osiell.com)
* Adrià Gil Sorribes <adria.gil@forgeflow.com> (https://www.forgeflow.com)

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 ABF OSIELL <http://osiell.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<report id="action_report_mrp_bom_comparison"
name="mrp_bom_comparison.report_mrp_bom_comparison"
model="wizard.mrp.bom.comparison"
string="BoM Differences"
report_type="qweb-pdf"/>
</odoo>

View File

@@ -4,9 +4,9 @@
<odoo>
<template id="report_mrp_bom_comparison">
<t t-call="report.html_container">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.internal_layout">
<t t-call="web.internal_layout">
<div class="page">
<table class="table table-condensed">
<thead>

View File

@@ -11,16 +11,16 @@ class TestMrpBomComparison(TestMrpCommon):
super(TestMrpBomComparison, self).setUp()
# bom_3 (product_6) -> bom_2 (product_5) -> bom_1 (product_4)
self.wiz_model = self.env['wizard.mrp.bom.comparison']
self.product_1.default_code = u"P1"
self.product_2.default_code = u"P2"
self.product_3.default_code = u"P3"
self.product_4.default_code = u"P4-BOM_1"
self.product_5.default_code = u"P5-BOM_2"
self.product_6.default_code = u"P6-BOM_3"
self.product_1.default_code = "P1"
self.product_2.default_code = "P2"
self.product_3.default_code = "P3"
self.product_4.default_code = "P4-BOM_1"
self.product_5.default_code = "P5-BOM_2"
self.product_6.default_code = "P6-BOM_3"
# Create a 'new_bom_1' from 'bom_1'
self.new_product_4 = self.product_4.copy(
{'default_code': u"P4-NEW_BOM_1"})
{'default_code': "P4-NEW_BOM_1"})
self.new_bom_1 = self.bom_1.copy({
'product_id': self.new_product_4.id,
'product_tmpl_id': self.new_product_4.product_tmpl_id.id,
@@ -32,7 +32,7 @@ class TestMrpBomComparison(TestMrpCommon):
# Create a 'new_bom_2' from 'bom_2'
self.new_product_5 = self.product_5.copy(
{'default_code': u"P5-NEW_BOM_2"})
{'default_code': "P5-NEW_BOM_2"})
self.new_bom_2 = self.bom_2.copy({
'product_id': self.new_product_5.id,
'product_tmpl_id': self.new_product_5.product_tmpl_id.id,

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 ABF OSIELL <http://osiell.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<report id="action_report_mrp_bom_comparison"
name="mrp_bom_comparison.report_mrp_bom_comparison"
model="wizard.mrp.bom.comparison"
string="BoM Differences"
report_type="qweb-pdf"/>
</odoo>

View File

@@ -63,24 +63,24 @@ class WizardMrpBomComparison(models.TransientModel):
])
bom1_id = fields.Many2one(
'mrp.bom', u"BoM v1", required=True,
'mrp.bom', "BoM v1", required=True,
domain=_func_domain_bom_id)
bom2_id = fields.Many2one(
'mrp.bom', u"BoM v2", required=True,
'mrp.bom', "BoM v2", required=True,
domain=_func_domain_bom_id)
line_ids = fields.One2many(
'wizard.mrp.bom.comparison.line', 'wiz_id', u"Differences")
'wizard.mrp.bom.comparison.line', 'wiz_id', "Differences")
line_changed_ids = fields.One2many(
'wizard.mrp.bom.comparison.line', 'wiz_id', u"Products updated",
'wizard.mrp.bom.comparison.line', 'wiz_id', "Products updated",
domain=[('state', '=', 'changed')])
line_added_ids = fields.One2many(
'wizard.mrp.bom.comparison.line', 'wiz_id', u"Products added",
'wizard.mrp.bom.comparison.line', 'wiz_id', "Products added",
domain=[('state', '=', 'added')])
line_removed_ids = fields.One2many(
'wizard.mrp.bom.comparison.line', 'wiz_id', u"Products removed",
'wizard.mrp.bom.comparison.line', 'wiz_id', "Products removed",
domain=[('state', '=', 'removed')])
total_qty = fields.Float(
u"Total qty",
"Total qty",
digits=dp.get_precision('Product Unit of Measure'),
compute='_compute_total_qty')
@@ -164,7 +164,7 @@ class WizardMrpBomComparison(models.TransientModel):
# from the same wizard
self.line_ids.unlink()
_logger.info(
u"BoM comparison between '%s' and '%s'...",
"BoM comparison between '%s' and '%s'...",
self.bom1_id.product_tmpl_id.default_code,
self.bom2_id.product_tmpl_id.default_code)
comparison_line_model = self.env['wizard.mrp.bom.comparison.line']
@@ -186,7 +186,7 @@ class WizardMrpBomComparison(models.TransientModel):
'state': 'changed',
}
_logger.info(
u"\tProduct updated: %s (ID=%s) %s -> %s",
"\tProduct updated: %s (ID=%s) %s -> %s",
v1['product_code'], p_id,
v1['bom_qty'], v2['bom_qty'])
comparison_line_model.create(vals)
@@ -201,7 +201,7 @@ class WizardMrpBomComparison(models.TransientModel):
'state': 'added',
}
_logger.info(
u"\tProduct added: %s (ID=%s) -> %s",
"\tProduct added: %s (ID=%s) -> %s",
v2['product_code'], p_id, vals['diff_qty'])
comparison_line_model.create(vals)
for p_id in diff.removed():
@@ -215,33 +215,33 @@ class WizardMrpBomComparison(models.TransientModel):
'state': 'removed',
}
_logger.info(
u"\tProduct removed: %s (ID=%s) -> %s",
"\tProduct removed: %s (ID=%s) -> %s",
v1['product_code'], p_id, vals['diff_qty'])
comparison_line_model.create(vals)
_logger.info(
u"BoM comparison between '%s' and '%s': printing report...",
"BoM comparison between '%s' and '%s': printing report...",
self.bom1_id.product_tmpl_id.default_code,
self.bom2_id.product_tmpl_id.default_code)
# Return the report
return self.env['report'].get_action(
self, 'mrp_bom_comparison.report_mrp_bom_comparison')
return self.env.ref(
'mrp_bom_comparison.action_report_mrp_bom_comparison').report_action(self)
class WizardMrpBomComparisonLine(models.TransientModel):
_name = 'wizard.mrp.bom.comparison.line'
_description = "BoM line difference"
wiz_id = fields.Many2one('wizard.mrp.bom.comparison', u"Wizard")
product_id = fields.Many2one('product.product', u"Product")
wiz_id = fields.Many2one('wizard.mrp.bom.comparison', "Wizard")
product_id = fields.Many2one('product.product', "Product")
bom1_qty = fields.Float(
u"v1-Qty", digits=dp.get_precision('Product Unit of Measure'))
"v1-Qty", digits=dp.get_precision('Product Unit of Measure'))
bom2_qty = fields.Float(
u"v2-Qty", digits=dp.get_precision('Product Unit of Measure'))
"v2-Qty", digits=dp.get_precision('Product Unit of Measure'))
diff_qty = fields.Float(
u"Qty gap", digits=dp.get_precision('Product Unit of Measure'))
"Qty gap", digits=dp.get_precision('Product Unit of Measure'))
state = fields.Selection(
[('changed', u"Changed"),
('added', u"Added"),
('removed', u"Removed"),
[('changed', "Changed"),
('added', "Added"),
('removed', "Removed"),
],
u"State")
"State")