mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] account_move_line_stock_info: Migration to 13.0
This commit is contained in:
committed by
Joan Mateu Jordi
parent
d5820be782
commit
1c0c30a5f5
@@ -14,13 +14,13 @@ Account Move Line Stock Info
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/account_move_line_stock_info
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/account_move_line_stock_info
|
||||
:alt: OCA/stock-logistics-warehouse
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-account_move_line_stock_info
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-account_move_line_stock_info
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/153/12.0
|
||||
:target: https://runbot.odoo-community.org/runbot/153/13.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -38,9 +38,9 @@ Usage
|
||||
* The stock manager can check the journal items by accessing to 'Inventory >
|
||||
Reports > Stock moves'.
|
||||
|
||||
* A user belonging to the group 'Accounting & Finance/Adviser' can review the
|
||||
* 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 > Adviser > Journal Entries (or Journal items)'.
|
||||
'Invoicing > Accounting > Journal Entries (or Journal items)'.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
@@ -48,7 +48,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20account_move_line_stock_info%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20account_move_line_stock_info%0Aversion:%2013.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.
|
||||
|
||||
@@ -65,6 +65,7 @@ Contributors
|
||||
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
* Lois Rilo <lois.rilo@eficent.com>
|
||||
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
@@ -79,6 +80,6 @@ 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/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/account_move_line_stock_info>`_ project on GitHub.
|
||||
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/account_move_line_stock_info>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# © 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# Copyright 2019 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# © 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# Copyright 2019 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
|
||||
|
||||
@@ -13,10 +13,10 @@ class StockMove(models.Model):
|
||||
|
||||
@api.model
|
||||
def _prepare_account_move_line(
|
||||
self, qty, cost, credit_account_id, debit_account_id
|
||||
self, qty, cost, credit_account_id, debit_account_id, description
|
||||
):
|
||||
res = super(StockMove, self)._prepare_account_move_line(
|
||||
qty, cost, credit_account_id, debit_account_id
|
||||
qty, cost, credit_account_id, debit_account_id, description
|
||||
)
|
||||
for line in res:
|
||||
line[2]["stock_move_id"] = self.id
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
* Lois Rilo <lois.rilo@eficent.com>
|
||||
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
* The stock manager can check the journal items by accessing to 'Inventory >
|
||||
Reports > Stock moves'.
|
||||
|
||||
* A user belonging to the group 'Accounting & Finance/Adviser' can review the
|
||||
* 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 > Adviser > Journal Entries (or Journal items)'.
|
||||
'Invoicing > Accounting > Journal Entries (or Journal items)'.
|
||||
|
||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" 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" 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" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/account_move_line_stock_info"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-account_move_line_stock_info"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" 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" 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" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/account_move_line_stock_info"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-account_move_line_stock_info"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module adds the stock move to the account move lines that it generates.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
@@ -387,9 +387,9 @@ ul.auto-toc {
|
||||
<ul class="simple">
|
||||
<li>The stock manager can check the journal items by accessing to ‘Inventory >
|
||||
Reports > Stock moves’.</li>
|
||||
<li>A user belonging to the group ‘Accounting & Finance/Adviser’ can review the
|
||||
<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 > Adviser > Journal Entries (or Journal items)’.</li>
|
||||
‘Invoicing > Accounting > Journal Entries (or Journal items)’.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
@@ -397,7 +397,7 @@ details of a move that is associated to a journal item through
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/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 smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20account_move_line_stock_info%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20account_move_line_stock_info%0Aversion:%2013.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">
|
||||
@@ -413,6 +413,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<ul class="simple">
|
||||
<li>Jordi Ballester Alomar <<a class="reference external" href="mailto:jordi.ballester@eficent.com">jordi.ballester@eficent.com</a>></li>
|
||||
<li>Lois Rilo <<a class="reference external" href="mailto:lois.rilo@eficent.com">lois.rilo@eficent.com</a>></li>
|
||||
<li>Pimolnat Suntian <<a class="reference external" href="mailto:pimolnats@ecosoft.co.th">pimolnats@ecosoft.co.th</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
@@ -422,7 +423,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<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/stock-logistics-warehouse/tree/12.0/account_move_line_stock_info">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/account_move_line_stock_info">OCA/stock-logistics-warehouse</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>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import test_account_move_line_stock_move
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# © 2015 Eficent Business and IT Consulting Services S.L. (www.eficent.com)
|
||||
# Copyright 2019 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
@@ -11,35 +11,32 @@ class TestAccountMoveLineStockInfo(TransactionCase):
|
||||
self.product_ctg_model = self.env["product.category"]
|
||||
self.acc_type_model = self.env["account.account.type"]
|
||||
self.account_model = self.env["account.account"]
|
||||
self.aml_model = self.env["account.move.line"]
|
||||
self.stock_picking_model = self.env["stock.picking"]
|
||||
self.stock_move_model = self.env["stock.move"]
|
||||
self.res_users_model = self.env["res.users"]
|
||||
|
||||
self.partner1 = self.env.ref("base.res_partner_1")
|
||||
self.location_stock = self.env.ref("stock.stock_location_stock")
|
||||
self.location_supplier = self.env.ref("stock.stock_location_suppliers")
|
||||
self.location_customer = self.env.ref("stock.stock_location_customers")
|
||||
self.company = self.env.ref("base.main_company")
|
||||
self.picking_type_in = self.env.ref("stock.picking_type_in")
|
||||
self.picking_type_out = self.env.ref("stock.picking_type_out")
|
||||
self.group_stock_user = self.env.ref("stock.group_stock_user")
|
||||
self.group_stock_manager = self.env.ref("stock.group_stock_manager")
|
||||
self.group_account_invoice = self.env.ref("account.group_account_invoice")
|
||||
self.group_account_manager = self.env.ref("account.group_account_manager")
|
||||
|
||||
# Create account for Goods Received Not Invoiced
|
||||
acc_type = self._create_account_type("equity", "other")
|
||||
acc_type = self._create_account_type("equity", "other", "equity")
|
||||
name = "Goods Received Not Invoiced"
|
||||
code = "grni"
|
||||
self.account_grni = self._create_account(acc_type, name, code, self.company)
|
||||
|
||||
# Create account for Cost of Goods Sold
|
||||
acc_type = self._create_account_type("expense", "other")
|
||||
acc_type = self._create_account_type("expense", "other", "expense")
|
||||
name = "Cost of Goods Sold"
|
||||
code = "cogs"
|
||||
self.account_cogs = self._create_account(acc_type, name, code, self.company)
|
||||
# Create account for Inventory
|
||||
acc_type = self._create_account_type("asset", "other")
|
||||
acc_type = self._create_account_type("asset", "other", "asset")
|
||||
name = "Inventory"
|
||||
code = "inventory"
|
||||
self.account_inventory = self._create_account(
|
||||
@@ -47,12 +44,11 @@ class TestAccountMoveLineStockInfo(TransactionCase):
|
||||
)
|
||||
# Create Product
|
||||
self.product = self._create_product()
|
||||
# company
|
||||
|
||||
# Create users
|
||||
self.stock_user = self._create_user(
|
||||
"stock_user",
|
||||
[self.group_stock_user, self.group_account_invoice],
|
||||
self.stock_manager = self._create_user(
|
||||
"stock_manager",
|
||||
[self.group_stock_manager, self.group_account_invoice],
|
||||
self.company,
|
||||
)
|
||||
self.account_invoice = self._create_user(
|
||||
@@ -78,8 +74,10 @@ class TestAccountMoveLineStockInfo(TransactionCase):
|
||||
)
|
||||
return user.id
|
||||
|
||||
def _create_account_type(self, name, a_type):
|
||||
acc_type = self.acc_type_model.create({"name": name, "type": a_type})
|
||||
def _create_account_type(self, name, a_type, internal_group):
|
||||
acc_type = self.acc_type_model.create(
|
||||
{"name": name, "type": a_type, "internal_group": internal_group}
|
||||
)
|
||||
return acc_type
|
||||
|
||||
def _create_account(self, acc_type, name, code, company):
|
||||
@@ -96,10 +94,12 @@ class TestAccountMoveLineStockInfo(TransactionCase):
|
||||
|
||||
def _create_product(self):
|
||||
"""Create a Product."""
|
||||
# group_ids = [group.id for group in groups]
|
||||
product_ctg = self.product_ctg_model.create(
|
||||
{
|
||||
"name": "test_product_ctg",
|
||||
"property_valuation": "real_time",
|
||||
"property_stock_account_input_categ_id": self.account_grni.id,
|
||||
"property_stock_account_output_categ_id": self.account_cogs.id,
|
||||
"property_stock_valuation_account_id": self.account_inventory.id,
|
||||
}
|
||||
)
|
||||
@@ -110,16 +110,13 @@ class TestAccountMoveLineStockInfo(TransactionCase):
|
||||
"type": "product",
|
||||
"standard_price": 1.0,
|
||||
"list_price": 1.0,
|
||||
"valuation": "real_time",
|
||||
"property_stock_account_input": self.account_grni.id,
|
||||
"property_stock_account_output": self.account_cogs.id,
|
||||
}
|
||||
)
|
||||
return product
|
||||
|
||||
def _create_picking(self, picking_type, location, location_dest):
|
||||
|
||||
picking = self.stock_picking_model.sudo(self.stock_user).create(
|
||||
picking = self.stock_picking_model.with_user(self.stock_manager).create(
|
||||
{
|
||||
"picking_type_id": picking_type.id,
|
||||
"location_id": location.id,
|
||||
@@ -158,7 +155,6 @@ class TestAccountMoveLineStockInfo(TransactionCase):
|
||||
for move in picking_in.move_lines:
|
||||
self.assertEqual(len(move.account_move_line_ids), 2)
|
||||
for aml in move.account_move_line_ids:
|
||||
self.assertEqual(aml.name, move.name)
|
||||
account_move_line = aml
|
||||
|
||||
picking_out = self._create_picking(
|
||||
@@ -170,17 +166,9 @@ class TestAccountMoveLineStockInfo(TransactionCase):
|
||||
|
||||
for move in picking_out.move_lines:
|
||||
self.assertEqual(len(move.account_move_line_ids), 2)
|
||||
for aml in move.account_move_line_ids:
|
||||
self.assertEqual(aml.name, move.name)
|
||||
|
||||
# Test that the account invoice user can access to the stock info
|
||||
self.assertEqual(
|
||||
account_move_line.sudo(self.account_invoice).stock_move_id.name,
|
||||
account_move_line.sudo(self.account_invoice).name,
|
||||
)
|
||||
self.assertTrue(account_move_line.with_user(self.account_invoice).stock_move_id)
|
||||
|
||||
# Test that the account manager can access to the stock info
|
||||
self.assertEqual(
|
||||
account_move_line.sudo(self.account_manager).stock_move_id.name,
|
||||
account_move_line.sudo(self.account_manager).name,
|
||||
)
|
||||
self.assertTrue(account_move_line.with_user(self.account_manager).stock_move_id)
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_move_picking_form" model="ir.ui.view">
|
||||
<field name="name">stock.move.form</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_move_picking_form"/>
|
||||
<record id="view_picking_form" model="ir.ui.view">
|
||||
<field name="name">stock.picking.form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="quants_grp" position="after">
|
||||
<xpath expr="//notebook//form//field[@name='description_picking']" position="after">
|
||||
<group name="account_move_lines_grp"
|
||||
string="Journal Items" colspan="4">
|
||||
<field name="account_move_line_ids" readonly="1"
|
||||
nolabel="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user