Skip to content

Commit e75042f

Browse files
committed
[IMP] mrp_project_analytic: "from child" check massive action button
This action is a techical one, and it should be fired only for those productions that have wrong values for their children, because it unsets the check for children production journal items and, then, set check properly for these children, when required. E.g. for a production that have children productions and these productions have children itself, it should only affect the two lower levels, leeaving upper level without changes.
1 parent 943819c commit e75042f

5 files changed

Lines changed: 82 additions & 13 deletions

File tree

mrp_project_analytic/__manifest__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
""",
99
"author": "Solvos",
1010
"license": "LGPL-3",
11-
"version": "15.0.2.0.0",
11+
"version": "15.0.2.1.0",
1212
"category": "Manufacturing",
1313
"website": "https://github.com/solvosci/slv-manufacture",
1414
"depends": ["mrp_project", "mrp_account"],
1515
"data": [
1616
"views/account_move_line_view.xml",
17+
"views/mrp_production_views.xml",
1718
],
1819
"installable": True,
1920
"post_init_hook": "post_init_hook",

mrp_project_analytic/i18n/es.po

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: Odoo Server 15.0\n"
88
"Report-Msgid-Bugs-To: \n"
9-
"POT-Creation-Date: 2025-03-05 11:35+0000\n"
10-
"PO-Revision-Date: 2025-03-05 11:35+0000\n"
9+
"POT-Creation-Date: 2025-05-13 06:54+0000\n"
10+
"PO-Revision-Date: 2025-05-13 08:57+0200\n"
1111
"Last-Translator: \n"
1212
"Language-Team: \n"
13+
"Language: es\n"
1314
"MIME-Version: 1.0\n"
1415
"Content-Type: text/plain; charset=UTF-8\n"
15-
"Content-Transfer-Encoding: \n"
16-
"Plural-Forms: \n"
16+
"Content-Transfer-Encoding: 8bit\n"
17+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
18+
"X-Generator: Poedit 3.4.2\n"
1719

1820
#. module: mrp_project_analytic
1921
#: model:ir.model.fields,field_description:mrp_project_analytic.field_account_move_line__analytic_mrp_from_child
@@ -22,19 +24,31 @@ msgstr "Proviene de Fab. hija"
2224

2325
#. module: mrp_project_analytic
2426
#: model:ir.model.fields,field_description:mrp_project_analytic.field_account_move_line__analytic_mrp_unbuilt
25-
msgid "Analytic Mrp Unbuilded"
26-
msgstr "Proviene de una deconstrucción"
27+
msgid "Analytic Mrp Unbuilt"
28+
msgstr ""
2729

2830
#. module: mrp_project_analytic
2931
#: model:ir.model,name:mrp_project_analytic.model_account_move_line
3032
msgid "Journal Item"
3133
msgstr "Apunte contable"
3234

35+
#. module: mrp_project_analytic
36+
#: code:addons/mrp_project_analytic/models/mrp_production.py:0
37+
#, python-format
38+
msgid "Only Production Managers can do this."
39+
msgstr "Solo Administradores de Fabricación pueden realizar esta operación."
40+
3341
#. module: mrp_project_analytic
3442
#: model:ir.model,name:mrp_project_analytic.model_mrp_production
3543
msgid "Production Order"
3644
msgstr "Orden de producción"
3745

46+
#. module: mrp_project_analytic
47+
#: model:ir.actions.server,name:mrp_project_analytic.action_duplicate_ticket
48+
#: model_terms:ir.ui.view,arch_db:mrp_project_analytic.mrp_production_form_view
49+
msgid "Set 'From Child' for journal items"
50+
msgstr "Establece \"prov. de fab. hija\" en apuntes"
51+
3852
#. module: mrp_project_analytic
3953
#: model:ir.model,name:mrp_project_analytic.model_mrp_unbuild
4054
msgid "Unbuild Order"

mrp_project_analytic/i18n/mrp_project_analytic.pot

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: Odoo Server 15.0\n"
88
"Report-Msgid-Bugs-To: \n"
9-
"POT-Creation-Date: 2025-03-05 11:35+0000\n"
10-
"PO-Revision-Date: 2025-03-05 11:35+0000\n"
9+
"POT-Creation-Date: 2025-05-13 06:54+0000\n"
10+
"PO-Revision-Date: 2025-05-13 06:54+0000\n"
1111
"Last-Translator: \n"
1212
"Language-Team: \n"
1313
"MIME-Version: 1.0\n"
@@ -22,19 +22,31 @@ msgstr ""
2222

2323
#. module: mrp_project_analytic
2424
#: model:ir.model.fields,field_description:mrp_project_analytic.field_account_move_line__analytic_mrp_unbuilt
25-
msgid "Analytic Mrp Unbuilded"
25+
msgid "Analytic Mrp Unbuilt"
2626
msgstr ""
2727

2828
#. module: mrp_project_analytic
2929
#: model:ir.model,name:mrp_project_analytic.model_account_move_line
3030
msgid "Journal Item"
3131
msgstr ""
3232

33+
#. module: mrp_project_analytic
34+
#: code:addons/mrp_project_analytic/models/mrp_production.py:0
35+
#, python-format
36+
msgid "Only Production Managers can do this."
37+
msgstr ""
38+
3339
#. module: mrp_project_analytic
3440
#: model:ir.model,name:mrp_project_analytic.model_mrp_production
3541
msgid "Production Order"
3642
msgstr ""
3743

44+
#. module: mrp_project_analytic
45+
#: model:ir.actions.server,name:mrp_project_analytic.action_duplicate_ticket
46+
#: model_terms:ir.ui.view,arch_db:mrp_project_analytic.mrp_production_form_view
47+
msgid "Set 'From Child' for journal items"
48+
msgstr ""
49+
3850
#. module: mrp_project_analytic
3951
#: model:ir.model,name:mrp_project_analytic.model_mrp_unbuild
4052
msgid "Unbuild Order"

mrp_project_analytic/models/mrp_production.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# © 2022 Solvos Consultoría Informática (<http://www.solvos.es>)
22
# License LGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html
33

4-
from odoo import models
4+
from odoo import _, models
5+
from odoo.exceptions import ValidationError
56

67

78
class ManufactureOrder(models.Model):
@@ -56,15 +57,26 @@ def _get_from_child_acount_move_lines(self):
5657

5758
return aml_ids
5859

59-
def mark_analytic_mrp_from_child(self):
60+
def mark_analytic_mrp_from_child(self, reset_all=False):
6061
aml_ids = self._get_from_child_acount_move_lines()
6162

6263
if aml_ids:
64+
if reset_all:
65+
aml_ids.write({"analytic_mrp_from_child": False})
6366
debit_aml_ids = aml_ids.filtered(lambda x: x.debit > 0)
6467
debit_aml_ids.write({
6568
"analytic_mrp_from_child": True,
6669
})
67-
70+
71+
def action_mark_analytic_mrp_from_child(self):
72+
if not self.env.user.has_group("mrp.group_mrp_manager"):
73+
raise ValidationError(_("Only Production Managers can do this."))
74+
for mrp in self.browse(
75+
self.env.context.get("active_ids", self.ids)
76+
).filtered(lambda x: x.state == "done"):
77+
# TODO mark_analytic_mrp_from_child is singleton at this point
78+
mrp.mark_analytic_mrp_from_child(reset_all=True)
79+
6880
def button_mark_done(self):
6981
res = super().button_mark_done()
7082
self.mark_analytic_mrp_from_child()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="mrp_production_form_view" model="ir.ui.view">
4+
<field name="name">mrp.production.form (in mrp_project_analytic)</field>
5+
<field name="model">mrp.production</field>
6+
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
7+
<field name="arch" type="xml">
8+
<button name="button_unbuild" position="after">
9+
<button
10+
name="action_mark_analytic_mrp_from_child"
11+
type="object"
12+
string="Set 'From Child' for journal items"
13+
attrs="{'invisible': [('state', '!=', 'done')]}"
14+
groups="base.group_no_one"
15+
/>
16+
</button>
17+
</field>
18+
</record>
19+
20+
<record id="action_duplicate_ticket" model="ir.actions.server">
21+
<field name="name">Set 'From Child' for journal items</field>
22+
<field name="model_id" ref="mrp.model_mrp_production" />
23+
<field name="binding_model_id" ref="mrp.model_mrp_production" />
24+
<field name="binding_view_types">list</field>
25+
<field name="state">code</field>
26+
<field name="code">
27+
action = model.action_mark_analytic_mrp_from_child()
28+
</field>
29+
</record>
30+
</odoo>

0 commit comments

Comments
 (0)