Skip to content

Commit 513373d

Browse files
[IMP] mrp_project_analytic_purchase: change function due to improved mrp_project_analytic
1 parent e75042f commit 513373d

7 files changed

Lines changed: 100 additions & 7 deletions

File tree

mrp_project_analytic_purchase/__manifest__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
""",
99
"author": "Solvos",
1010
"license": "LGPL-3",
11-
"version": "15.0.1.0.0",
11+
"version": "15.0.1.1.0",
1212
"category": "Manufacturing",
1313
"website": "https://github.com/solvosci/slv-manufacture",
1414
"depends": ["mrp_project_analytic", "purchase"],
15-
"data": [],
15+
"data": [
16+
"views/account_move_line_view.xml",
17+
],
1618
"installable": True,
1719
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * mrp_project_analytic_purchase
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2025-05-16 09:26+0000\n"
10+
"PO-Revision-Date: 2025-05-16 09:26+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: mrp_project_analytic_purchase
19+
#: model:ir.model.fields,field_description:mrp_project_analytic_purchase.field_account_move_line__analytic_mrp_from_purchase
20+
msgid "Analytic Mrp From Purchase"
21+
msgstr "Proviene de una compra"
22+
23+
#. module: mrp_project_analytic_purchase
24+
#: model:ir.model,name:mrp_project_analytic_purchase.model_account_move_line
25+
msgid "Journal Item"
26+
msgstr "Apunte contable"
27+
28+
#. module: mrp_project_analytic_purchase
29+
#: model:ir.model,name:mrp_project_analytic_purchase.model_mrp_production
30+
msgid "Production Order"
31+
msgstr "Orden de producción"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * mrp_project_analytic_purchase
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2025-05-16 09:26+0000\n"
10+
"PO-Revision-Date: 2025-05-16 09:26+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: mrp_project_analytic_purchase
19+
#: model:ir.model.fields,field_description:mrp_project_analytic_purchase.field_account_move_line__analytic_mrp_from_purchase
20+
msgid "Analytic Mrp From Purchase"
21+
msgstr ""
22+
23+
#. module: mrp_project_analytic_purchase
24+
#: model:ir.model,name:mrp_project_analytic_purchase.model_account_move_line
25+
msgid "Journal Item"
26+
msgstr ""
27+
28+
#. module: mrp_project_analytic_purchase
29+
#: model:ir.model,name:mrp_project_analytic_purchase.model_mrp_production
30+
msgid "Production Order"
31+
msgstr ""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import mrp_production
2+
from . import account_move_line
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# © 2024 Solvos Consultoría Informática (<http://www.solvos.es>)
2+
# License LGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html
3+
4+
from odoo import models, fields
5+
6+
7+
class AccountMoveLine(models.Model):
8+
_inherit = "account.move.line"
9+
10+
analytic_mrp_from_purchase = fields.Boolean(readonly=True)

mrp_project_analytic_purchase/models/mrp_production.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
class ManufactureOrder(models.Model):
88
_inherit = "mrp.production"
99

10-
def _prepare_mark_account_move_ids(self):
11-
res = super(ManufactureOrder, self)._prepare_mark_account_move_ids()
10+
def _get_from_child_acount_move_lines(self):
11+
res = super(ManufactureOrder, self)._get_from_child_acount_move_lines()
1212

1313
pol_obj = self.env['purchase.order.line'].sudo()
14-
for move in self.move_raw_ids.filtered(lambda x: x.state == "done"):
14+
for move in self.move_raw_ids.filtered(lambda x: x.state == "done"):
1515
project_id = move.raw_material_production_id.project_id
1616
# TODO: Check slow query
17-
mr_qty = sum(self.sudo().search([('project_id', '=', project_id.id), ('state', '=', 'done')]).move_raw_ids.filtered(lambda x: x.product_id == move.product_id.id).mapped('quantity_done'))
17+
mr_qty = sum(self.sudo().search([('project_id', '=', project_id.id), ('state', '=', 'done')]).move_raw_ids.filtered(lambda x: x.product_id.id == move.product_id.id).mapped('quantity_done'))
1818
mt_total = mr_qty + move.product_uom_qty
1919
pol_qty = sum(pol_obj.search([('account_analytic_id', '=', project_id.analytic_account_id.id), ('state', 'in', ['purchase', 'done']), ('product_id', '=', move.product_id.id)]).mapped('product_uom_qty'))
2020

2121
if mt_total <= pol_qty:
22-
res |= move.sudo().mapped('account_move_ids.line_ids')
22+
move.sudo().mapped('account_move_ids.line_ids').write({
23+
"analytic_mrp_from_purchase": True,
24+
})
2325

2426
return res
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
4+
<record id="account_move_line_form_view" model="ir.ui.view">
5+
<field name="name">account.move.line.form</field>
6+
<field name="model">account.move.line</field>
7+
<field name="inherit_id" ref="account.view_move_line_form" />
8+
<field name="arch" type="xml">
9+
<xpath expr="//field[@name='analytic_tag_ids']" position="after">
10+
<field name="analytic_mrp_from_purchase" widget="boolean_toggle"
11+
groups="analytic.group_analytic_accounting" />
12+
</xpath>
13+
</field>
14+
</record>
15+
16+
</odoo>

0 commit comments

Comments
 (0)