Skip to content

Commit 54004d5

Browse files
committed
[ADD] account_analytic_maintenance_stock
Propagate analytic distribution to maintenance stock moves. When stock moves are linked to maintenance equipment through the maintenance_stock module, this module propagates the analytic distribution configured on the equipment to the stock move. The implementation is intentionally limited to stock moves related to maintenance equipment and only fills the analytic distribution when it has not already been set, preserving values provided by other modules. Currently maintenance_stock does not provide a dedicated hook to initialize stock move values, so this module overrides create() with a narrowly scoped implementation.
1 parent 2a57058 commit 54004d5

12 files changed

Lines changed: 645 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
==================================
2+
Account Analytic Maintenance Stock
3+
==================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:f825ebdcf934fe61459535686bb101109f49613acb08235a9cf255dbd93d8032
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
20+
:target: https://github.com/OCA/account-analytic/tree/18.0/account_analytic_maintenance_stock
21+
:alt: OCA/account-analytic
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/account-analytic-18-0/account-analytic-18-0-account_analytic_maintenance_stock
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-analytic&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module propagates the analytic distribution from maintenance
32+
equipment to stock moves created for maintenance operations.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Usage
40+
=====
41+
42+
Go to *Maintenance > Equipment*. Configure an analytic distribution on
43+
the equipment. Create a maintenance request for the equipment. Create
44+
stock operations related to the maintenance request. Verify that the
45+
generated stock moves inherit the equipment analytic distribution.
46+
47+
Bug Tracker
48+
===========
49+
50+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/issues>`_.
51+
In case of trouble, please check there if your issue has already been reported.
52+
If you spotted it first, help us to smash it by providing a detailed and welcomed
53+
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20account_analytic_maintenance_stock%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
54+
55+
Do not contact contributors directly about support or help with technical issues.
56+
57+
Credits
58+
=======
59+
60+
Authors
61+
-------
62+
63+
* Spearhead
64+
* Ricardo MC
65+
66+
Contributors
67+
------------
68+
69+
- Spearhead
70+
- Ricardo Maldonado <rmaldonado@spearhead.global>
71+
72+
Maintainers
73+
-----------
74+
75+
This module is maintained by the OCA.
76+
77+
.. image:: https://odoo-community.org/logo.png
78+
:alt: Odoo Community Association
79+
:target: https://odoo-community.org
80+
81+
OCA, or the Odoo Community Association, is a nonprofit organization whose
82+
mission is to support the collaborative development of Odoo features and
83+
promote its widespread use.
84+
85+
This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/18.0/account_analytic_maintenance_stock>`_ project on GitHub.
86+
87+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Account Analytic Maintenance Stock",
3+
"version": "18.0.1.0.0",
4+
"summary": """ Propagate analytic distribution from maintenance
5+
equipment to stock moves """,
6+
"author": "Spearhead, Ricardo MC, Odoo Community Association (OCA)",
7+
"website": "https://github.com/OCA/account-analytic",
8+
"category": "Analytic Accounting",
9+
"license": "AGPL-3",
10+
"depends": [
11+
"account_analytic_maintenance",
12+
"maintenance_stock",
13+
"stock_analytic",
14+
],
15+
"data": [],
16+
"installable": True,
17+
"application": False,
18+
"auto_install": False,
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import stock_move
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from odoo import api, models
2+
3+
4+
class StockMove(models.Model):
5+
_inherit = "stock.move"
6+
7+
@api.depends("picking_id.maintenance_request_id")
8+
def _compute_analytic_distribution(self):
9+
res = super()._compute_analytic_distribution()
10+
for move in self:
11+
equipment = move.picking_id.maintenance_request_id.equipment_id
12+
if equipment and equipment.analytic_distribution:
13+
move.analytic_distribution = equipment.analytic_distribution
14+
return res
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Spearhead
2+
- Ricardo Maldonado \<<rmaldonado@spearhead.global>\>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This module propagates the analytic distribution from maintenance
2+
equipment to stock moves created for maintenance operations.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Go to *Maintenance > Equipment*.
2+
Configure an analytic distribution on the equipment.
3+
Create a maintenance request for the equipment.
4+
Create stock operations related to the maintenance request.
5+
Verify that the generated stock moves inherit the equipment analytic
6+
distribution.

0 commit comments

Comments
 (0)