-
-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by quentinDupont
- Loading branch information
Showing
17 changed files
with
833 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
=================================== | ||
MRP BoM Line Net and Gross Quantity | ||
=================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:d28bb95908f9af39d805d7e789f88a5158f5b703b9ea7673eda7e3a0838d385c | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
: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/16.0/mrp_bom_line_net_qty | ||
:alt: OCA/manufacture | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_line_net_qty | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Handle gross and net quantity on BoM lines thanks to loss percentage | ||
Fill quantity (original one is 'gross quantity') : it set automatically 'net quantity' | ||
Fill loss percentage, Odoo will show two buttons to calculate net or 'gross quantity' | ||
You can also set 'net quantity' and calculate 'gross quantity' with loss percentage | ||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_net_qty/static/description/mrp_bom_line_net_qty.gif | ||
|
||
Here are the added fields | ||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_net_qty/static/description/change_net_qty_before.png | ||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_net_qty/static/description/change_net_qty_after.png | ||
|
||
/!\ Line with difference with theorical values are set in yellow | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
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 to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_line_net_qty%0Aversion:%2016.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. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* GRAP | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Quentin Dupont ([email protected]) | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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. | ||
|
||
.. |maintainer-quentinDupont| image:: https://github.com/quentinDupont.png?size=40px | ||
:target: https://github.com/quentinDupont | ||
:alt: quentinDupont | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-quentinDupont| | ||
|
||
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/16.0/mrp_bom_line_net_qty>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (C) 2023-Today: GRAP (http://www.grap.coop) | ||
# @author: Quentin Dupont | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "MRP BoM Line Net and Gross Quantity", | ||
"version": "16.0.1.0.0", | ||
"category": "Manufacturing", | ||
"author": "GRAP, Odoo Community Association (OCA)", | ||
"maintainers": ["quentinDupont"], | ||
"website": "https://github.com/OCA/manufacture", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"mrp", | ||
], | ||
"data": [ | ||
"views/view_mrp_bom.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mrp_bom_line_net_qty | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-02-26 16:45+0000\n" | ||
"PO-Revision-Date: 2024-02-26 16:45+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model_terms:ir.ui.view,arch_db:mrp_bom_line_net_qty.view_mrp_bom_form | ||
msgid ">" | ||
msgstr "" | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model:ir.model,name:mrp_bom_line_net_qty.model_mrp_bom_line | ||
msgid "Bill of Material Line" | ||
msgstr "Ligne de nomenclature" | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model:ir.model.fields,field_description:mrp_bom_line_net_qty.field_mrp_bom_line__diff_product_qty_gross_net | ||
msgid "Diff Product Qty Gross Net" | ||
msgstr "" | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model:ir.model.fields,field_description:mrp_bom_line_net_qty.field_mrp_bom_line__loss_percentage | ||
msgid "Loss %" | ||
msgstr "Perte %" | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model:ir.model.fields,field_description:mrp_bom_line_net_qty.field_mrp_bom_line__product_qty_net | ||
msgid "Net quantity" | ||
msgstr "Qté nette" | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model:ir.model.fields,help:mrp_bom_line_net_qty.field_mrp_bom_line__loss_percentage | ||
msgid "Percentage loss, for example, when grating carrots" | ||
msgstr "Pourcentage de perte, après avoir râper des carottes par exemple." | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#. odoo-python | ||
#: code:addons/mrp_bom_line_net_qty/models/mrp_bom_line.py:0 | ||
#, python-format | ||
msgid "" | ||
"Setting gross quantity with 100% loss makes no sense.\n" | ||
"Change this value." | ||
msgstr "" | ||
"Définir une quantité brute avec 100% de perte n'a pas de sens.\n" | ||
"Changer cette valeur de pourcentage." | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model_terms:ir.ui.view,arch_db:mrp_bom_line_net_qty.view_mrp_bom_form | ||
msgid "" | ||
"This will set product gross quantity with net quantity and loss percentage" | ||
msgstr "" | ||
"Cela définira la quantité brut de produits grâce à la quantité net et le " | ||
"pourcentage de perte." | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model_terms:ir.ui.view,arch_db:mrp_bom_line_net_qty.view_mrp_bom_form | ||
msgid "" | ||
"This will set product net quantity with gross quantity and loss percentage" | ||
msgstr "" | ||
"Cela définira la quantité net de produits grâce à la quantité brute et le " | ||
"pourcentage de perte." | ||
|
||
#. module: mrp_bom_line_net_qty | ||
#: model:ir.model.fields,help:mrp_bom_line_net_qty.field_mrp_bom_line__product_qty_net | ||
msgid "" | ||
"Weight after any preparation, e.g. weight of carrots after they are grated." | ||
msgstr "" | ||
"Poids net après une préparation, après avoir râper des carottes par exemple." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import mrp_bom_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) | ||
# @author: Quentin DUPONT ([email protected]) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class MrpBomLine(models.Model): | ||
_inherit = "mrp.bom.line" | ||
|
||
product_qty_net = fields.Float( | ||
string="Net quantity", | ||
help="Quantity after process", | ||
digits="Product Unit of Measure", | ||
) | ||
loss_percentage = fields.Float( | ||
string="Loss %", | ||
help="Percentage loss during process", | ||
digits=(16, 2), | ||
) | ||
diff_product_qty_gross_net = fields.Float( | ||
digits="Product Price", | ||
compute="_compute_diff_product_qty_gross_net", | ||
) | ||
|
||
# Functions to change product fields | ||
def calculate_qty_net_theoretical(self, product_qty_gross, loss_percentage): | ||
return (1 - loss_percentage / 100) * product_qty_gross | ||
|
||
@api.depends("product_qty", "product_qty_net", "loss_percentage") | ||
def _compute_diff_product_qty_gross_net(self): | ||
for bom_line in self: | ||
_bom_line_qty_net_theorical = self.calculate_qty_net_theoretical( | ||
bom_line.product_qty, bom_line.loss_percentage | ||
) | ||
_diff_product_qty_gross_net = round( | ||
(bom_line.product_qty_net - _bom_line_qty_net_theorical), 2 | ||
) | ||
bom_line.diff_product_qty_gross_net = _diff_product_qty_gross_net | ||
|
||
# Two buttons to handle two cases : you base your price on net qty or gross qty | ||
def set_product_qty_net(self): | ||
for bom_line in self.filtered(lambda x: x.product_qty): | ||
bom_line.product_qty_net = self.calculate_qty_net_theoretical( | ||
bom_line.product_qty, bom_line.loss_percentage | ||
) | ||
|
||
def set_product_qty_gross(self): | ||
for bom_line in self.filtered(lambda x: x.product_qty_net): | ||
if bom_line.loss_percentage == 100: | ||
raise UserError( | ||
_( | ||
"Setting gross quantity with 100% loss makes no sense.\n" | ||
"Change this value." | ||
) | ||
) | ||
else: | ||
bom_line.product_qty = bom_line.product_qty_net / ( | ||
1 - bom_line.loss_percentage / 100 | ||
) | ||
|
||
# If you change mandatory field product_qty (gross qty), the net quantity adapts | ||
@api.onchange("product_qty") | ||
def _onchange_product_qty(self): | ||
for bom_line in self: | ||
bom_line.product_qty_net = bom_line.product_qty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Quentin Dupont ([email protected]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Handle gross and net quantity on BoM lines thanks to loss percentage | ||
Fill quantity (original one is 'gross quantity') : it set automatically 'net quantity' | ||
Fill loss percentage, Odoo will show two buttons to calculate net or 'gross quantity' | ||
You can also set 'net quantity' and calculate 'gross quantity' with loss percentage | ||
|
||
.. figure:: ../static/description/mrp_bom_line_net_qty.gif | ||
|
||
Here are the added fields | ||
|
||
.. figure:: ../static/description/change_net_qty_before.png | ||
|
||
.. figure:: ../static/description/change_net_qty_after.png | ||
|
||
/!\ Line with difference with theorical values are set in yellow |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.