Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions mrp_byproduct_auto_pick/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
=======================
MRP Byproduct Auto Pick
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:dfcc3449be75e3410a25b67d6cc2215a9fddde1ac736df990144a7b55a651ca7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/18.0/mrp_byproduct_auto_pick
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-18-0/manufacture-18-0-mrp_byproduct_auto_pick
: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=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

In standard Odoo, the quantity of a byproduct on a manufacturing order
is recomputed from the producing quantity whenever it is (re)evaluated,
including when *Produce All* fills the producing quantity automatically.
As a result, a quantity that an operator entered manually on a byproduct
line is silently reset to the quantity to produce, unless the line
happens to be marked as picked.

This module adds an *Auto-pick Manually Edited Byproducts* option to
manufacturing orders (defaulted from a company-wide setting) to keep the
manually entered byproduct quantity: when an operator edits the quantity
of a byproduct line on an enabled manufacturing order, the line is
automatically marked as picked so its value is preserved through
*Produce All*.

Byproduct lines that are not edited keep the standard behavior and still
scale with the producing quantity.

**Table of contents**

.. contents::
:local:

Configuration
=============

1. **Company default** -- Go to *Manufacturing > Configuration >
Settings* and tick *Auto-pick Manually Edited Byproducts*. New
manufacturing orders will inherit this value.

2. **Per manufacturing order** -- The *Auto-pick Manually Edited
Byproducts* checkbox on a manufacturing order can be toggled
individually, overriding the company default for that order.

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_byproduct_auto_pick%0Aversion:%2018.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
-------

* Quartile

Contributors
------------

- `Quartile <https://www.quartile.co>`__:

- Aung Ko Ko Lin

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-kanda999| image:: https://github.com/kanda999.png?size=40px
:target: https://github.com/kanda999
:alt: kanda999
.. |maintainer-aungkokolin1997| image:: https://github.com/aungkokolin1997.png?size=40px
:target: https://github.com/aungkokolin1997
:alt: aungkokolin1997

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-kanda999| |maintainer-aungkokolin1997|

This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/18.0/mrp_byproduct_auto_pick>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mrp_byproduct_auto_pick/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions mrp_byproduct_auto_pick/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "MRP Byproduct Auto Pick",
"summary": "Keep manually entered byproduct quantities instead of "
"resetting them to the quantity to produce",
"version": "18.0.1.0.0",
"category": "Manufacturing",
"license": "AGPL-3",
"author": "Quartile, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture",
"depends": ["mrp"],
"data": [
"views/mrp_production_views.xml",
"views/res_config_settings_views.xml",
],
"maintainers": ["kanda999", "aungkokolin1997"],
"installable": True,
}
4 changes: 4 additions & 0 deletions mrp_byproduct_auto_pick/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import mrp_production
from . import res_company
from . import res_config_settings
from . import stock_move
22 changes: 22 additions & 0 deletions mrp_byproduct_auto_pick/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class MrpProduction(models.Model):
_inherit = "mrp.production"

byproduct_auto_pick = fields.Boolean(
string="Auto-pick Manually Edited Byproducts",
compute="_compute_byproduct_auto_pick",
store=True,
readonly=False,
help="Keep manually entered byproduct quantities on manufacturing "
"orders instead of resetting them to the quantity to produce.",
)

@api.depends("company_id")
def _compute_byproduct_auto_pick(self):
for production in self:
production.byproduct_auto_pick = production.company_id.byproduct_auto_pick
10 changes: 10 additions & 0 deletions mrp_byproduct_auto_pick/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

byproduct_auto_pick = fields.Boolean(string="Auto-pick Manually Edited Byproducts")
13 changes: 13 additions & 0 deletions mrp_byproduct_auto_pick/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

byproduct_auto_pick = fields.Boolean(
related="company_id.byproduct_auto_pick",
readonly=False,
)
41 changes: 41 additions & 0 deletions mrp_byproduct_auto_pick/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models
from odoo.tools import float_compare


class StockMove(models.Model):
_inherit = "stock.move"

def _is_auto_pick_byproduct(self):
self.ensure_one()
production = self.production_id
return bool(production) and self.product_id != production.product_id

def _should_auto_pick_byproduct(self):
self.ensure_one()
return self.production_id.byproduct_auto_pick

def write(self, vals):
# The MO recompute writes byproduct quantities through
# `_set_quantity_done` under the `auto_conso` context; we must not
# pick those.
if self.env.context.get("auto_conso"):
return super().write(vals)
candidates = self.filtered(
lambda move: not move.picked
and move._is_auto_pick_byproduct()
and move._should_auto_pick_byproduct()
)
quantity_before = {move.id: move.quantity for move in candidates}
res = super().write(vals)
candidates.filtered(
lambda move: float_compare(
move.quantity,
quantity_before[move.id],
precision_rounding=move.product_uom.rounding,
)
!= 0
).picked = True
return res
3 changes: 3 additions & 0 deletions mrp_byproduct_auto_pick/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions mrp_byproduct_auto_pick/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1. **Company default** -- Go to *Manufacturing \> Configuration \> Settings*
and tick *Auto-pick Manually Edited Byproducts*. New manufacturing orders
will inherit this value.

2. **Per manufacturing order** -- The *Auto-pick Manually Edited Byproducts*
checkbox on a manufacturing order can be toggled individually, overriding
the company default for that order.
2 changes: 2 additions & 0 deletions mrp_byproduct_auto_pick/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Quartile](https://www.quartile.co):
- Aung Ko Ko Lin
15 changes: 15 additions & 0 deletions mrp_byproduct_auto_pick/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
In standard Odoo, the quantity of a byproduct on a manufacturing order is
recomputed from the producing quantity whenever it is (re)evaluated, including
when *Produce All* fills the producing quantity automatically. As a result, a
quantity that an operator entered manually on a byproduct line is silently
reset to the quantity to produce, unless the line happens to be marked as
picked.

This module adds an *Auto-pick Manually Edited Byproducts* option to
manufacturing orders (defaulted from a company-wide setting) to keep the
manually entered byproduct quantity: when an operator edits the quantity of a
byproduct line on an enabled manufacturing order, the line is automatically
marked as picked so its value is preserved through *Produce All*.

Byproduct lines that are not edited keep the standard behavior and still scale
with the producing quantity.
Loading
Loading