[MIG] account_move_line_stock_info: Migration to 13.0

This commit is contained in:
ps-tubtim
2020-01-07 10:15:49 +07:00
committed by Joan Mateu Jordi
parent d5820be782
commit 1c0c30a5f5
9 changed files with 48 additions and 57 deletions

View File

@@ -14,13 +14,13 @@ Account Move Line Stock Info
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github .. |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 :alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |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 :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -38,9 +38,9 @@ Usage
* The stock manager can check the journal items by accessing to 'Inventory > * The stock manager can check the journal items by accessing to 'Inventory >
Reports > Stock moves'. 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 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 Bug Tracker
=========== ===========
@@ -48,7 +48,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_. 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. 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 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. Do not contact contributors directly about support or help with technical issues.
@@ -65,6 +65,7 @@ Contributors
* Jordi Ballester Alomar <jordi.ballester@eficent.com> * Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@eficent.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
Maintainers 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. 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. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,5 +1,5 @@
# © 2016 Eficent Business and IT Consulting Services S.L. # Copyright 2019 ForgeFlow S.L. (https://www.forgeflow.com)
# 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 odoo import fields, models from odoo import fields, models

View File

@@ -1,5 +1,5 @@
# © 2016 Eficent Business and IT Consulting Services S.L. # Copyright 2019 ForgeFlow S.L. (https://www.forgeflow.com)
# 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 odoo import api, fields, models from odoo import api, fields, models
@@ -13,10 +13,10 @@ class StockMove(models.Model):
@api.model @api.model
def _prepare_account_move_line( 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( 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: for line in res:
line[2]["stock_move_id"] = self.id line[2]["stock_move_id"] = self.id

View File

@@ -1,2 +1,3 @@
* Jordi Ballester Alomar <jordi.ballester@eficent.com> * Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@eficent.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>

View File

@@ -1,6 +1,6 @@
* The stock manager can check the journal items by accessing to 'Inventory > * The stock manager can check the journal items by accessing to 'Inventory >
Reports > Stock moves'. 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 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)'.

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! 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>This module adds the stock move to the account move lines that it generates.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
@@ -387,9 +387,9 @@ ul.auto-toc {
<ul class="simple"> <ul class="simple">
<li>The stock manager can check the journal items by accessing to Inventory &gt; <li>The stock manager can check the journal items by accessing to Inventory &gt;
Reports &gt; Stock moves.</li> Reports &gt; Stock moves.</li>
<li>A user belonging to the group Accounting &amp; 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 details of a move that is associated to a journal item through
Invoicing &gt; Adviser &gt; Journal Entries (or Journal items).</li> Invoicing &gt; Accounting &gt; Journal Entries (or Journal items).</li>
</ul> </ul>
</div> </div>
<div class="section" id="bug-tracker"> <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>. <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. 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 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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <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"> <ul class="simple">
<li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;eficent.com">jordi.ballester&#64;eficent.com</a>&gt;</li> <li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;eficent.com">jordi.ballester&#64;eficent.com</a>&gt;</li>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li> <li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li>
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <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 <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> 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> <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> </div>

View File

@@ -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 from . import test_account_move_line_stock_move

View File

@@ -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). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase from odoo.tests.common import TransactionCase
@@ -11,35 +11,32 @@ class TestAccountMoveLineStockInfo(TransactionCase):
self.product_ctg_model = self.env["product.category"] self.product_ctg_model = self.env["product.category"]
self.acc_type_model = self.env["account.account.type"] self.acc_type_model = self.env["account.account.type"]
self.account_model = self.env["account.account"] 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_picking_model = self.env["stock.picking"]
self.stock_move_model = self.env["stock.move"]
self.res_users_model = self.env["res.users"] 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_stock = self.env.ref("stock.stock_location_stock")
self.location_supplier = self.env.ref("stock.stock_location_suppliers") self.location_supplier = self.env.ref("stock.stock_location_suppliers")
self.location_customer = self.env.ref("stock.stock_location_customers") self.location_customer = self.env.ref("stock.stock_location_customers")
self.company = self.env.ref("base.main_company") self.company = self.env.ref("base.main_company")
self.picking_type_in = self.env.ref("stock.picking_type_in") self.picking_type_in = self.env.ref("stock.picking_type_in")
self.picking_type_out = self.env.ref("stock.picking_type_out") 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_invoice = self.env.ref("account.group_account_invoice")
self.group_account_manager = self.env.ref("account.group_account_manager") self.group_account_manager = self.env.ref("account.group_account_manager")
# Create account for Goods Received Not Invoiced # 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" name = "Goods Received Not Invoiced"
code = "grni" code = "grni"
self.account_grni = self._create_account(acc_type, name, code, self.company) self.account_grni = self._create_account(acc_type, name, code, self.company)
# Create account for Cost of Goods Sold # 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" name = "Cost of Goods Sold"
code = "cogs" code = "cogs"
self.account_cogs = self._create_account(acc_type, name, code, self.company) self.account_cogs = self._create_account(acc_type, name, code, self.company)
# Create account for Inventory # Create account for Inventory
acc_type = self._create_account_type("asset", "other") acc_type = self._create_account_type("asset", "other", "asset")
name = "Inventory" name = "Inventory"
code = "inventory" code = "inventory"
self.account_inventory = self._create_account( self.account_inventory = self._create_account(
@@ -47,12 +44,11 @@ class TestAccountMoveLineStockInfo(TransactionCase):
) )
# Create Product # Create Product
self.product = self._create_product() self.product = self._create_product()
# company
# Create users # Create users
self.stock_user = self._create_user( self.stock_manager = self._create_user(
"stock_user", "stock_manager",
[self.group_stock_user, self.group_account_invoice], [self.group_stock_manager, self.group_account_invoice],
self.company, self.company,
) )
self.account_invoice = self._create_user( self.account_invoice = self._create_user(
@@ -78,8 +74,10 @@ class TestAccountMoveLineStockInfo(TransactionCase):
) )
return user.id return user.id
def _create_account_type(self, name, a_type): def _create_account_type(self, name, a_type, internal_group):
acc_type = self.acc_type_model.create({"name": name, "type": a_type}) acc_type = self.acc_type_model.create(
{"name": name, "type": a_type, "internal_group": internal_group}
)
return acc_type return acc_type
def _create_account(self, acc_type, name, code, company): def _create_account(self, acc_type, name, code, company):
@@ -96,10 +94,12 @@ class TestAccountMoveLineStockInfo(TransactionCase):
def _create_product(self): def _create_product(self):
"""Create a Product.""" """Create a Product."""
# group_ids = [group.id for group in groups]
product_ctg = self.product_ctg_model.create( product_ctg = self.product_ctg_model.create(
{ {
"name": "test_product_ctg", "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, "property_stock_valuation_account_id": self.account_inventory.id,
} }
) )
@@ -110,16 +110,13 @@ class TestAccountMoveLineStockInfo(TransactionCase):
"type": "product", "type": "product",
"standard_price": 1.0, "standard_price": 1.0,
"list_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 return product
def _create_picking(self, picking_type, location, location_dest): 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, "picking_type_id": picking_type.id,
"location_id": location.id, "location_id": location.id,
@@ -158,7 +155,6 @@ class TestAccountMoveLineStockInfo(TransactionCase):
for move in picking_in.move_lines: for move in picking_in.move_lines:
self.assertEqual(len(move.account_move_line_ids), 2) self.assertEqual(len(move.account_move_line_ids), 2)
for aml in move.account_move_line_ids: for aml in move.account_move_line_ids:
self.assertEqual(aml.name, move.name)
account_move_line = aml account_move_line = aml
picking_out = self._create_picking( picking_out = self._create_picking(
@@ -170,17 +166,9 @@ class TestAccountMoveLineStockInfo(TransactionCase):
for move in picking_out.move_lines: for move in picking_out.move_lines:
self.assertEqual(len(move.account_move_line_ids), 2) 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 # Test that the account invoice user can access to the stock info
self.assertEqual( self.assertTrue(account_move_line.with_user(self.account_invoice).stock_move_id)
account_move_line.sudo(self.account_invoice).stock_move_id.name,
account_move_line.sudo(self.account_invoice).name,
)
# Test that the account manager can access to the stock info # Test that the account manager can access to the stock info
self.assertEqual( self.assertTrue(account_move_line.with_user(self.account_manager).stock_move_id)
account_move_line.sudo(self.account_manager).stock_move_id.name,
account_move_line.sudo(self.account_manager).name,
)

View File

@@ -17,18 +17,18 @@
</record> </record>
<record id="view_move_picking_form" model="ir.ui.view"> <record id="view_picking_form" model="ir.ui.view">
<field name="name">stock.move.form</field> <field name="name">stock.picking.form</field>
<field name="model">stock.move</field> <field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_move_picking_form"/> <field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml"> <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" <group name="account_move_lines_grp"
string="Journal Items" colspan="4"> string="Journal Items" colspan="4">
<field name="account_move_line_ids" readonly="1" <field name="account_move_line_ids" readonly="1"
nolabel="1"/> nolabel="1"/>
</group> </group>
</group> </xpath>
</field> </field>
</record> </record>