Merge PR #1232 into 15.0

Signed-off-by LoisRForgeFlow
This commit is contained in:
OCA-git-bot
2024-03-13 09:28:50 +00:00
23 changed files with 1242 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
==========================
Account Move Line Mrp Info
==========================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:16dc4b397b258cadf401a8e7a1d5602329edf1025b208952ba257d5f1801a2cb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/15.0/account_move_line_mrp_info
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-account_move_line_mrp_info
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=15.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module adds the manufacturing orders and unbuild orders to the account move lines that it generates.
**Table of contents**
.. contents::
:local:
Usage
=====
* The stock manager can check the journal items by accessing to 'Manufacturing >
Operations > Manufacturing Orders> Journal Items' and 'Manufacturing >
Operations > Unbuild Orders> Journal Items.
* A user belonging to the group 'Show Full Accounting Features' can review the
details of a move that is associated to a journal item through
'Invoicing > Accounting > Journal Entries (or Journal items)'.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20account_move_line_mrp_info%0Aversion:%2015.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
~~~~~~~
* ForgeFlow
Contributors
~~~~~~~~~~~~
* Nuria Xifre Martin <nuria.xifre@forgeflow.com>
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/manufacture <https://github.com/OCA/manufacture/tree/15.0/account_move_line_mrp_info>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from .hooks import pre_init_hook

View File

@@ -0,0 +1,18 @@
# © 2023 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Move Line Mrp Info",
"version": "15.0.1.0.0",
"author": "ForgeFlow," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture",
"category": "Manufacture",
"depends": ["account_move_line_stock_info", "mrp"],
"installable": True,
"pre_init_hook": "pre_init_hook",
"license": "AGPL-3",
"data": [
"security/ir.model.access.csv",
"views/account_move_line_view.xml",
"views/mrp_production_view.xml",
],
}

View File

@@ -0,0 +1,51 @@
import logging
from psycopg2 import sql
def pre_init_hook(cr):
"""Precreate move_type and fill with appropriate values to prevent
a MemoryError when the ORM attempts to call its compute method on a large
amount of preexisting moves. Note that the order of the mapping is
important as one move can have move lines on accounts of multiple types
and the move type is set in the order of precedence."""
logger = logging.getLogger(__name__)
logger.info("Add mrp_info")
cr.execute(
"ALTER TABLE account_move_line ADD COLUMN IF NOT EXISTS mrp_production_id INTEGER"
)
query = sql.SQL(
"""
with q2 as (
select aml.id as account_move_id,
coalesce(sm.production_id,sm.raw_material_production_id) as mrp_id
from account_move_line aml
inner join stock_move sm
on sm.id=aml.stock_move_id
where coalesce(sm.production_id,sm.raw_material_production_id) is not null)
update account_move_line
set mrp_production_id = q2.mrp_id
from q2
where q2.account_move_id=account_move_line.id;
"""
)
cr.execute(query)
cr.execute(
"ALTER TABLE account_move_line ADD COLUMN IF NOT EXISTS unbuild_id INTEGER"
)
query = sql.SQL(
"""
with q2 as (
select aml.id as account_move_id,
sm.unbuild_id as unb_id
from account_move_line aml
inner join stock_move sm
on sm.id=aml.stock_move_id
where sm.unbuild_id is not null)
update account_move_line
set unbuild_id = q2.unb_id
from q2
where q2.account_move_id=account_move_line.id;
"""
)
cr.execute(query)

View File

@@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_line_mrp_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \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: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__account_move_line_ids
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__account_move_line_ids
msgid "Account Move Line"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__display_name
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__display_name
msgid "Display Name"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__id
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__id
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__id
msgid "ID"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_account_move_line
msgid "Journal Item"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.actions.act_window,name:account_move_line_mrp_info.action_view_journal_items
#: model_terms:ir.ui.view,arch_db:account_move_line_mrp_info.mrp_production_form_view
#: model_terms:ir.ui.view,arch_db:account_move_line_mrp_info.mrp_unbuild_form_view
msgid "Journal Items"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production____last_update
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild____last_update
msgid "Last Modified on"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__mrp_production_id
msgid "Manufacturing Order"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_mrp_production
msgid "Production Order"
msgstr ""
#. module: account_move_line_mrp_info
#: model_terms:ir.actions.act_window,help:account_move_line_mrp_info.action_view_journal_items
msgid "There's no journal item yet"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_mrp_unbuild
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__unbuild_id
msgid "Unbuild Order"
msgstr ""

View File

@@ -0,0 +1,75 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_line_mrp_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__account_move_line_ids
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__account_move_line_ids
msgid "Account Move Line"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__display_name
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__display_name
msgid "Display Name"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__id
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__id
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__id
msgid "ID"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_account_move_line
msgid "Journal Item"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.actions.act_window,name:account_move_line_mrp_info.action_view_journal_items
#: model_terms:ir.ui.view,arch_db:account_move_line_mrp_info.mrp_production_form_view
#: model_terms:ir.ui.view,arch_db:account_move_line_mrp_info.mrp_unbuild_form_view
msgid "Journal Items"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production____last_update
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild____last_update
msgid "Last Modified on"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__mrp_production_id
msgid "Manufacturing Order"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_mrp_production
msgid "Production Order"
msgstr ""
#. module: account_move_line_mrp_info
#: model_terms:ir.actions.act_window,help:account_move_line_mrp_info.action_view_journal_items
msgid "There's no journal item yet"
msgstr ""
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_mrp_unbuild
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__unbuild_id
msgid "Unbuild Order"
msgstr ""

View File

@@ -0,0 +1,77 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_line_mrp_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-23 00:01+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__account_move_line_ids
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__account_move_line_ids
msgid "Account Move Line"
msgstr "Línea de movimiento de cuenta"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__display_name
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__display_name
msgid "Display Name"
msgstr "Mostrar nombre"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__id
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__id
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__id
msgid "ID"
msgstr "ID (identificación)"
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_account_move_line
msgid "Journal Item"
msgstr "Elemento de diario"
#. module: account_move_line_mrp_info
#: model:ir.actions.act_window,name:account_move_line_mrp_info.action_view_journal_items
#: model_terms:ir.ui.view,arch_db:account_move_line_mrp_info.mrp_production_form_view
#: model_terms:ir.ui.view,arch_db:account_move_line_mrp_info.mrp_unbuild_form_view
msgid "Journal Items"
msgstr "Artículos Diarios"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production____last_update
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__mrp_production_id
msgid "Manufacturing Order"
msgstr "Orden de Manufactura"
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_mrp_production
msgid "Production Order"
msgstr "Orden de Producción"
#. module: account_move_line_mrp_info
#: model_terms:ir.actions.act_window,help:account_move_line_mrp_info.action_view_journal_items
msgid "There's no journal item yet"
msgstr "Aún no hay ningún artículo en el diario"
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_mrp_unbuild
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__unbuild_id
msgid "Unbuild Order"
msgstr "Orden de desestructuración"

View File

@@ -0,0 +1,77 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_line_mrp_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-12-22 13:44+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__account_move_line_ids
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__account_move_line_ids
msgid "Account Move Line"
msgstr "Riga movimento contabile"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__display_name
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__display_name
msgid "Display Name"
msgstr "Nome visualizzato"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__id
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production__id
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild__id
msgid "ID"
msgstr "ID"
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_account_move_line
msgid "Journal Item"
msgstr "Movimento contabile"
#. module: account_move_line_mrp_info
#: model:ir.actions.act_window,name:account_move_line_mrp_info.action_view_journal_items
#: model_terms:ir.ui.view,arch_db:account_move_line_mrp_info.mrp_production_form_view
#: model_terms:ir.ui.view,arch_db:account_move_line_mrp_info.mrp_unbuild_form_view
msgid "Journal Items"
msgstr "Movimenti contabili"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_production____last_update
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_mrp_unbuild____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"
#. module: account_move_line_mrp_info
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__mrp_production_id
msgid "Manufacturing Order"
msgstr "Ordine di produzione"
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_mrp_production
msgid "Production Order"
msgstr "Ordine di produzione"
#. module: account_move_line_mrp_info
#: model_terms:ir.actions.act_window,help:account_move_line_mrp_info.action_view_journal_items
msgid "There's no journal item yet"
msgstr "Non ci sono ancora movimenti contabili"
#. module: account_move_line_mrp_info
#: model:ir.model,name:account_move_line_mrp_info.model_mrp_unbuild
#: model:ir.model.fields,field_description:account_move_line_mrp_info.field_account_move_line__unbuild_id
msgid "Unbuild Order"
msgstr "Ordine di smontaggio"

View File

@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_move_line
from . import mrp_production

View File

@@ -0,0 +1,39 @@
# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
mrp_production_id = fields.Many2one(
comodel_name="mrp.production",
string="Manufacturing Order",
compute="_compute_mrp_production",
store=True,
)
unbuild_id = fields.Many2one(
comodel_name="mrp.unbuild",
string="Unbuild Order",
compute="_compute_mrp_unbuild",
store=True,
)
@api.depends("stock_move_id")
def _compute_mrp_production(self):
for rec in self:
if rec.stock_move_id.production_id:
rec.mrp_production_id = rec.stock_move_id.production_id.id
elif rec.stock_move_id.raw_material_production_id:
rec.mrp_production_id = rec.stock_move_id.raw_material_production_id.id
else:
rec.mrp_production_id = False
@api.depends("stock_move_id")
def _compute_mrp_unbuild(self):
for rec in self:
if rec.stock_move_id.unbuild_id:
rec.unbuild_id = rec.stock_move_id.unbuild_id.id
else:
rec.unbuild_id = False

View File

@@ -0,0 +1,57 @@
# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from ast import literal_eval
from odoo import fields, models
class MrpProduction(models.Model):
_inherit = "mrp.production"
account_move_line_ids = fields.One2many(
comodel_name="account.move.line", inverse_name="mrp_production_id", copy=False
)
def view_journal_items(self):
self.ensure_one()
domain = [
(
"id",
"in",
(self.account_move_line_ids).ids,
)
]
action = self.env["ir.actions.act_window"]._for_xml_id(
"account_move_line_mrp_info.action_view_journal_items"
)
context = literal_eval(action["context"])
context.update(self.env.context)
context["no_at_date"] = True
context["search_default_group_by_product_id"] = False
return dict(action, domain=domain, context=context)
class MrpUnbuild(models.Model):
_inherit = "mrp.unbuild"
account_move_line_ids = fields.One2many(
comodel_name="account.move.line", inverse_name="unbuild_id", copy=False
)
def view_journal_items(self):
self.ensure_one()
domain = [
(
"id",
"in",
(self.account_move_line_ids).ids,
)
]
action = self.env["ir.actions.act_window"]._for_xml_id(
"account_move_line_mrp_info.action_view_journal_items"
)
context = literal_eval(action["context"])
context.update(self.env.context)
context["no_at_date"] = True
context["search_default_group_by_product_id"] = False
return dict(action, domain=domain, context=context)

View File

@@ -0,0 +1 @@
* Nuria Xifre Martin <nuria.xifre@forgeflow.com>

View File

@@ -0,0 +1 @@
This module adds the manufacturing orders and unbuild orders to the account move lines that it generates.

View File

@@ -0,0 +1,7 @@
* The stock manager can check the journal items by accessing to 'Manufacturing >
Operations > Manufacturing Orders> Journal Items' and 'Manufacturing >
Operations > Unbuild Orders> Journal Items.
* A user belonging to the group 'Show Full Accounting Features' can review the
details of a move that is associated to a journal item through
'Invoicing > Accounting > Journal Entries (or Journal items)'.

View File

@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_move_line, account.move.line,account.model_account_move_line,stock.group_stock_manager,1,0,0,0
access_mrp_production_account_invoice,mrp.production account invoice,mrp.model_mrp_production,account.group_account_invoice,1,0,0,0
access_mrp_production_account_user,mrp.production account user,mrp.model_mrp_production,account.group_account_user,1,0,0,0
access_mrp_production_account_manager,mrp.production account user,mrp.model_mrp_production,account.group_account_manager,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_account_move_line account.move.line account.model_account_move_line stock.group_stock_manager 1 0 0 0
3 access_mrp_production_account_invoice mrp.production account invoice mrp.model_mrp_production account.group_account_invoice 1 0 0 0
4 access_mrp_production_account_user mrp.production account user mrp.model_mrp_production account.group_account_user 1 0 0 0
5 access_mrp_production_account_manager mrp.production account user mrp.model_mrp_production account.group_account_manager 1 0 0 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,433 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Account Move Line Mrp Info</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="account-move-line-mrp-info">
<h1 class="title">Account Move Line Mrp Info</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:16dc4b397b258cadf401a8e7a1d5602329edf1025b208952ba257d5f1801a2cb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/manufacture/tree/15.0/account_move_line_mrp_info"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-account_move_line_mrp_info"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/manufacture&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds the manufacturing orders and unbuild orders to the account move lines that it generates.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<ul class="simple">
<li>The stock manager can check the journal items by accessing to Manufacturing &gt;
Operations &gt; Manufacturing Orders&gt; Journal Items and Manufacturing &gt;
Operations &gt; Unbuild Orders&gt; Journal Items.</li>
<li>A user belonging to the group Show Full Accounting Features can review the
details of a move that is associated to a journal item through
Invoicing &gt; Accounting &gt; Journal Entries (or Journal items).</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20account_move_line_mrp_info%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>ForgeFlow</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Nuria Xifre Martin &lt;<a class="reference external" href="mailto:nuria.xifre&#64;forgeflow.com">nuria.xifre&#64;forgeflow.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/15.0/account_move_line_mrp_info">OCA/manufacture</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1 @@
from . import test_mrp_journal_items

View File

@@ -0,0 +1,159 @@
from odoo.tests import Form
from odoo.addons.mrp.tests.common import TestMrpCommon
class TestMrpOrder(TestMrpCommon):
def setUp(self):
super(TestMrpOrder, self).setUp()
self.stock_location = self.env.ref("stock.stock_location_stock")
self.env.ref("base.group_user").write(
{"implied_ids": [(4, self.env.ref("stock.group_production_lot").id)]}
)
def test_mrp_with_journal_items(self):
"""This test creates a Manufacturing orderand then check if the
Journal Items button links to the journal items of the order.
"""
journal_items_before_production = self.env["account.move.line"].search([]).ids
mo, bom, p_final, p1, p2 = self.generate_mo()
account = self.env["account.account"].create(
{
"name": "Test Account",
"code": "TestAccount1",
"user_type_id": self.env.ref("account.data_account_type_payable").id,
"reconcile": True,
}
)
location = self.env["stock.location"].search([("usage", "=", "production")])
location.valuation_in_account_id = account.id
location.valuation_out_account_id = account.id
pc = self.env["product.category"].create(
{
"name": "Category test",
"property_valuation": "real_time",
"property_cost_method": "fifo",
}
)
p1.categ_id = pc.id
p1.standard_price = 10
p2.categ_id = pc.id
p2.standard_price = 5
p_final.categ_id = pc.id
self.env["stock.quant"]._update_available_quantity(p1, self.stock_location, 100)
self.env["stock.quant"]._update_available_quantity(p2, self.stock_location, 5)
mo.action_assign()
mo_form = Form(mo)
mo_form.qty_producing = 5.0
mo = mo_form.save()
mo.button_mark_done()
journal_items_after_production = self.env["account.move.line"].search([]).ids
result = mo.view_journal_items()
domain = result["domain"]
mo_journal_items = list(domain[0][2])
difference_journal_items = list(
set(journal_items_after_production) - set(journal_items_before_production)
)
mo_journal_items.sort()
difference_journal_items.sort()
self.assertTrue(
difference_journal_items,
"There should be new journal items after doing the manufacturing order",
)
self.assertEqual(
result["res_model"],
"account.move.line",
"You should access to the model account.move.line",
)
self.assertEqual(
difference_journal_items,
mo_journal_items,
"You should have as domain the ids of the journal items",
)
class TestUnbuild(TestMrpCommon):
def setUp(self):
super(TestUnbuild, self).setUp()
self.stock_location = self.env.ref("stock.stock_location_stock")
self.env.ref("base.group_user").write(
{"implied_ids": [(4, self.env.ref("stock.group_production_lot").id)]}
)
def test_unbuild_with_journal_items(self):
"""This test creates an Unbuild order from a Manufacturing order and then check if the
Journal Items button links to the journal items of the order.
"""
mo, bom, p_final, p1, p2 = self.generate_mo()
account = self.env["account.account"].create(
{
"name": "Test Account",
"code": "TestAccount2",
"user_type_id": self.env.ref("account.data_account_type_payable").id,
"reconcile": True,
}
)
location = self.env["stock.location"].search([("usage", "=", "production")])
location.valuation_in_account_id = account.id
location.valuation_out_account_id = account.id
pc = self.env["product.category"].create(
{
"name": "Category test",
"property_valuation": "real_time",
"property_cost_method": "fifo",
}
)
p1.categ_id = pc.id
p1.standard_price = 10
p2.categ_id = pc.id
p2.standard_price = 5
p_final.categ_id = pc.id
self.env["stock.quant"]._update_available_quantity(p1, self.stock_location, 100)
self.env["stock.quant"]._update_available_quantity(p2, self.stock_location, 5)
mo.action_assign()
mo_form = Form(mo)
mo_form.qty_producing = 5.0
mo = mo_form.save()
mo.button_mark_done()
journal_items_before_unbuild = self.env["account.move.line"].search([]).ids
x = Form(self.env["mrp.unbuild"])
x.product_id = p_final
x.bom_id = bom
x.product_qty = 5
unbuild = x.save()
unbuild.action_unbuild()
journal_items_after_unbuild = self.env["account.move.line"].search([]).ids
result = unbuild.view_journal_items()
domain = result["domain"]
unbuild_journal_items = domain[0][2]
difference_journal_items = list(
set(journal_items_after_unbuild) - set(journal_items_before_unbuild)
)
unbuild_journal_items.sort()
difference_journal_items.sort()
self.assertTrue(
difference_journal_items,
"There should be new journal items after doing the unbuild",
)
self.assertEqual(
result["res_model"],
"account.move.line",
"You should access to the model account.move.line",
)
self.assertEqual(
difference_journal_items,
unbuild_journal_items,
"You should have as domain the ids of the journal items",
)

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_move_line_form" model="ir.ui.view">
<field name="name">account.move.line.form</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_form" />
<field name="arch" type="xml">
<field name="quantity" position="before">
<field name="mrp_production_id" />
<field name="unbuild_id" />
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="action_view_journal_items" model="ir.actions.act_window">
<field name="name">Journal Items</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.move.line</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_empty_folder">
There's no journal item yet
</p>
</field>
</record>
<record id="mrp_production_form_view" model="ir.ui.view">
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button
string="Journal Items"
type="object"
name="view_journal_items"
class="oe_stat_button"
icon="fa-th-list"
groups="base.group_no_one"
attrs="{'invisible': [('state', '!=', 'done')]}"
/>
</xpath>
</field>
</record>
<record id="mrp_unbuild_form_view" model="ir.ui.view">
<field name="model">mrp.unbuild</field>
<field name="inherit_id" ref="mrp.mrp_unbuild_form_view" />
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button
string="Journal Items"
type="object"
name="view_journal_items"
class="oe_stat_button"
icon="fa-th-list"
groups="base.group_no_one"
attrs="{'invisible': [('state', '=', 'draft')]}"
/>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1 @@
../../../../account_move_line_mrp_info

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)