Skip to content

Commit

Permalink
[ADD] mrp_subcontracting_analytic
Browse files Browse the repository at this point in the history
  • Loading branch information
yostashiro authored and AungKoKoLin1997 committed Jul 31, 2024
1 parent 636761e commit d4a9aa8
Show file tree
Hide file tree
Showing 13 changed files with 615 additions and 0 deletions.
78 changes: 78 additions & 0 deletions mrp_subcontracting_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
===========================
MRP Subcontracting Analytic
===========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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%2Faccount--analytic-lightgray.png?logo=github
:target: https://github.com/OCA/account-analytic/tree/16.0/mrp_subcontracting_analytic
:alt: OCA/account-analytic
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-analytic-16-0/account-analytic-16-0-mrp_subcontracting_analytic
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/87/16.0
:alt: Try me on Runbot

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

Propagates the analytic distribution of subcontracting receipt stock move to the
corresponding field of related manufacturing order.

This module depends on other OCA modules, stock_analytic and mrp_production_analytic.

**Table of contents**

.. contents::
:local:

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

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

* Quartile Limited

Contributors
~~~~~~~~~~~~

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

* Yoshi Tashiro

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/account-analytic <https://github.com/OCA/account-analytic/tree/16.0/mrp_subcontracting_analytic>`_ 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_subcontracting_analytic/__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_subcontracting_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "MRP Subcontracting Analytic",
"version": "16.0.1.0.0",
"author": "Quartile Limited, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"category": "Manufacturing/Manufacturing",
"license": "AGPL-3",
"depends": [
"mrp_subcontracting",
"mrp_stock_analytic",
],
"installable": True,
}
2 changes: 2 additions & 0 deletions mrp_subcontracting_analytic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_move
from . import stock_picking
23 changes: 23 additions & 0 deletions mrp_subcontracting_analytic/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


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

analytic_distribution = fields.Json(inverse="_inverse_analytic_distribution")

def _inverse_analytic_distribution(self):
for move in self:
if not move.is_subcontract:
continue
production = self.search(
[
("product_id", "=", move.product_id.id),
("move_dest_ids", "=", move.id),
]
).production_id
if production:
production.analytic_distribution = move.analytic_distribution
13 changes: 13 additions & 0 deletions mrp_subcontracting_analytic/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class StockPicking(models.Model):
_inherit = "stock.picking"

def _prepare_subcontract_mo_vals(self, subcontract_move, bom):
vals = super()._prepare_subcontract_mo_vals(subcontract_move, bom)
vals["analytic_distribution"] = subcontract_move.analytic_distribution
return vals
3 changes: 3 additions & 0 deletions mrp_subcontracting_analytic/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Quartile <https://www.quartile.co>`__:

* Yoshi Tashiro
4 changes: 4 additions & 0 deletions mrp_subcontracting_analytic/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Propagates the analytic distribution of subcontracting receipt stock move to the
corresponding field of related manufacturing order.

This module depends on other OCA modules, stock_analytic and mrp_production_analytic.
Loading

0 comments on commit d4a9aa8

Please sign in to comment.