Skip to content

Commit

Permalink
[16.0][ADD] product_last_mrp_info: In products new fields: "Last Manu…
Browse files Browse the repository at this point in the history
…facturing Order", and "Last Manufacturing Order Date". (#389)

Co-authored-by: Ana Juaristi <ajuaristio@gmail.com>
  • Loading branch information
alfredoavanzosc and anajuaristi authored Aug 2, 2024
1 parent 196bab7 commit 1a7a10c
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 0 deletions.
28 changes: 28 additions & 0 deletions product_last_mrp_info/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=====================
Product last mrp info
=====================

* In products new fields: "Last Manufacturing Order", and
"Last Manufacturing Order Date".

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

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/mrp-addons/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted
it first, help us smash it by providing detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Contributors
------------
* Ana Juaristi <ajuaristio@gmail.com>
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es>
3 changes: 3 additions & 0 deletions product_last_mrp_info/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
16 changes: 16 additions & 0 deletions product_last_mrp_info/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Product Last MRP Info",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"category": "Manufacturing",
"author": "Avanzosc",
"website": "https://github.com/avanzosc/mrp-addons",
"depends": [
"product",
"mrp",
],
"data": ["views/product_product_views.xml"],
"installable": True,
}
36 changes: 36 additions & 0 deletions product_last_mrp_info/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_last_mrp_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-16 11:00+0000\n"
"PO-Revision-Date: 2024-05-16 11:00+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_last_mrp_info
#: model:ir.model.fields,field_description:product_last_mrp_info.field_product_product__last_mrp_id
msgid "Last Manufacturing Order"
msgstr "Última OF"

#. module: product_last_mrp_info
#: model:ir.model.fields,field_description:product_last_mrp_info.field_product_product__last_mrp_date
msgid "Last Manufacturing Order Date"
msgstr "Última fecha OF"

#. module: product_last_mrp_info
#: model_terms:ir.ui.view,arch_db:product_last_mrp_info.product_normal_form_view
msgid "MRP"
msgstr "MRP"

#. module: product_last_mrp_info
#: model:ir.model,name:product_last_mrp_info.model_product_product
msgid "Product Variant"
msgstr "Variante de producto"
36 changes: 36 additions & 0 deletions product_last_mrp_info/i18n/product_last_mrp_info.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_last_mrp_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-16 11:00+0000\n"
"PO-Revision-Date: 2024-05-16 11:00+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_last_mrp_info
#: model:ir.model.fields,field_description:product_last_mrp_info.field_product_product__last_mrp_id
msgid "Last Manufacturing Order"
msgstr ""

#. module: product_last_mrp_info
#: model:ir.model.fields,field_description:product_last_mrp_info.field_product_product__last_mrp_date
msgid "Last Manufacturing Order Date"
msgstr ""

#. module: product_last_mrp_info
#: model_terms:ir.ui.view,arch_db:product_last_mrp_info.product_normal_form_view
msgid "MRP"
msgstr ""

#. module: product_last_mrp_info
#: model:ir.model,name:product_last_mrp_info.model_product_product
msgid "Product Variant"
msgstr ""
1 change: 1 addition & 0 deletions product_last_mrp_info/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_product
29 changes: 29 additions & 0 deletions product_last_mrp_info/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import fields, models


class ProductProduct(models.Model):
_inherit = "product.product"

last_mrp_id = fields.Many2one(
string="Last Manufacturing Order",
comodel_name="mrp.production",
compute="_compute_last_mrp_info",
)
last_mrp_date = fields.Datetime(
string="Last Manufacturing Order Date", compute="_compute_last_mrp_info"
)

def _compute_last_mrp_info(self):
for product in self:
production = self.env["mrp.production"].search(
[("product_id", "=", product.id), ("state", "=", "done")],
limit=1,
order="date_finished desc",
)
product._get_last_mrp_info(production)

def _get_last_mrp_info(self, production):
self.last_mrp_id = production.id
self.last_mrp_date = production.date_finished
37 changes: 37 additions & 0 deletions product_last_mrp_info/views/product_product_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<odoo>
<record id="product_normal_form_view" model="ir.ui.view">
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="arch" type="xml">
<page name="inventory" position="after">
<page
string="MRP"
name="page-mrp"
groups="mrp.group_mrp_user"
attrs="{'invisible':[('type', '=', 'service')]}"
>
<group name="group-mrp">
<field name="last_mrp_id" />
<field name="last_mrp_date" />
</group>
</page>
</page>
</field>
</record>

<record id="product_product_tree_view" model="ir.ui.view">
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_product_tree_view" />
<field name="arch" type="xml">
<field name="standard_price" position="before">
<field name="last_mrp_id" optional="show" groups="mrp.group_mrp_user" />
<field
name="last_mrp_date"
optional="show"
widget="date"
groups="mrp.group_mrp_user"
/>
</field>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/product_last_mrp_info/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 1a7a10c

Please sign in to comment.