Skip to content

Commit

Permalink
Merge pull request #251 from akretion/16.0-mig-mrp_raw_material_from_…
Browse files Browse the repository at this point in the history
…config

[16][MIG] mrp_raw_material_from_config
  • Loading branch information
florian-dacosta authored Sep 28, 2023
2 parents c240266 + a9bde56 commit 85123da
Show file tree
Hide file tree
Showing 9 changed files with 537 additions and 0 deletions.
68 changes: 68 additions & 0 deletions mrp_raw_material_from_config/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
============================
MRP Raw Material From Config
============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fak--odoo--incubator-lightgray.png?logo=github
:target: https://github.com/OCA/ak-odoo-incubator/tree/16.0/mrp_raw_material_from_config
:alt: OCA/ak-odoo-incubator
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/ak-odoo-incubator-16-0/ak-odoo-incubator-16-0-mrp_raw_material_from_config
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/ak-odoo-incubator&target_branch=16.0
:alt: Try me on Runboat

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

Compute MO's raw material from lot configuration

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/ak-odoo-incubator/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/ak-odoo-incubator/issues/new?body=module:%20mrp_raw_material_from_config%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
~~~~~~~

* Akretion

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.

This module is part of the `OCA/ak-odoo-incubator <https://github.com/OCA/ak-odoo-incubator/tree/16.0/mrp_raw_material_from_config>`_ 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_raw_material_from_config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions mrp_raw_material_from_config/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "MRP Raw Material From Config",
"version": "16.0.1.0.0",
"category": "Manufacture",
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/akretion/ak-odoo-incubator",
"license": "AGPL-3",
"depends": [
"sale_lot_config",
"mrp_restrict_lot",
],
"installable": True,
}
1 change: 1 addition & 0 deletions mrp_raw_material_from_config/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mrp_production
32 changes: 32 additions & 0 deletions mrp_raw_material_from_config/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


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

def _get_raw_material_from_config(self, original_moves_vals):
self.ensure_one()
return original_moves_vals

def _get_moves_raw_values(self):
moves_vals = super()._get_moves_raw_values()
production_move_vals = {x: [] for x in self}
for move_vals in moves_vals:
# manage case of onchange. we can't browse an NewId coming from an onchang
# but we always have only 1 MO if we come from an onchange.
if len(self) == 1:
current_mo = self
else:
current_mo = self.browse(move_vals["raw_material_production_id"])
production_move_vals[current_mo].append(move_vals)

final_moves_vals = []

for production, prod_moves_vals in production_move_vals.items():
final_prod_moves_vals = production._get_raw_material_from_config(
prod_moves_vals
)
final_moves_vals += final_prod_moves_vals
return final_moves_vals
1 change: 1 addition & 0 deletions mrp_raw_material_from_config/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compute MO's raw material from lot configuration
Loading

0 comments on commit 85123da

Please sign in to comment.