[MIG] account_move_line_purchase_info: Migration to 13.0
This commit is contained in:
parent
438d620eb6
commit
9d3033960c
@ -14,13 +14,13 @@ Account Move Line Purchase 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%2Faccount--financial--tools-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/account-financial-tools/tree/12.0/account_move_line_purchase_info
|
||||
:target: https://github.com/OCA/account-financial-tools/tree/13.0/account_move_line_purchase_info
|
||||
:alt: OCA/account-financial-tools
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/account-financial-tools-12-0/account-financial-tools-12-0-account_move_line_purchase_info
|
||||
:target: https://translation.odoo-community.org/projects/account-financial-tools-13-0/account-financial-tools-13-0-account_move_line_purchase_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/92/12.0
|
||||
:target: https://runbot.odoo-community.org/runbot/92/13.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@ -52,7 +52,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/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/account-financial-tools/issues/new?body=module:%20account_move_line_purchase_info%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_line_purchase_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.
|
||||
|
||||
@ -62,12 +62,12 @@ Credits
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Eficent
|
||||
* ForgeFlow
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
* Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
@ -82,6 +82,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/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/12.0/account_move_line_purchase_info>`_ project on GitHub.
|
||||
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/13.0/account_move_line_purchase_info>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
@ -1,12 +1,12 @@
|
||||
# Copyright 2017 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).
|
||||
|
||||
{
|
||||
"name": "Account Move Line Purchase Info",
|
||||
"summary": "Introduces the purchase order line to the journal items",
|
||||
"version": "12.0.2.0.0",
|
||||
"author": "Eficent, " "Odoo Community Association (OCA)",
|
||||
"version": "13.0.1.0.0",
|
||||
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
||||
"website": "https://www.github.com/OCA/account-financial-tools",
|
||||
"category": "Generic",
|
||||
"depends": ["purchase_stock"],
|
||||
|
@ -1,40 +0,0 @@
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
__name__ = "Upgrade to 12.0.2.0.0"
|
||||
|
||||
|
||||
def update_purchase_id_column(cr):
|
||||
cr.execute(
|
||||
"""SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name='account_move_line' AND
|
||||
column_name='purchase_id'"""
|
||||
)
|
||||
if not cr.fetchone():
|
||||
_logger.info("""Add column purchase_id to account_move_line""")
|
||||
cr.execute(
|
||||
"""
|
||||
ALTER TABLE account_move_line ADD COLUMN purchase_id integer;
|
||||
"""
|
||||
)
|
||||
_logger.info("""Updating values for purchase_id in account_move_line""")
|
||||
cr.execute(
|
||||
"""
|
||||
UPDATE account_move_line aml
|
||||
SET purchase_id = pol.order_id
|
||||
FROM purchase_order_line AS pol
|
||||
WHERE aml.purchase_line_id = pol.id
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
update_purchase_id_column(cr)
|
@ -1,4 +1,3 @@
|
||||
from . import account_move
|
||||
from . import account_invoice
|
||||
from . import purchase_order_line
|
||||
from . import stock_move
|
||||
|
@ -1,29 +0,0 @@
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# (www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
|
||||
_inherit = "account.invoice"
|
||||
|
||||
@api.model
|
||||
def invoice_line_move_line_get(self):
|
||||
res = super(AccountInvoice, self).invoice_line_move_line_get()
|
||||
|
||||
invoice_line_model = self.env["account.invoice.line"]
|
||||
for move_line_dict in res:
|
||||
if "invl_id" in move_line_dict:
|
||||
line = invoice_line_model.browse(move_line_dict["invl_id"])
|
||||
move_line_dict["purchase_line_id"] = line.purchase_line_id.id
|
||||
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def line_get_convert(self, line, part):
|
||||
res = super(AccountInvoice, self).line_get_convert(line, part)
|
||||
if line.get("purchase_line_id", False):
|
||||
res["purchase_line_id"] = line.get("purchase_line_id")
|
||||
return res
|
@ -1,5 +1,5 @@
|
||||
# Copyright 2017 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 import fields, models
|
||||
@ -9,13 +9,6 @@ class AccountMoveLine(models.Model):
|
||||
|
||||
_inherit = "account.move.line"
|
||||
|
||||
purchase_line_id = fields.Many2one(
|
||||
comodel_name="purchase.order.line",
|
||||
string="Purchase Order Line",
|
||||
ondelete="set null",
|
||||
index=True,
|
||||
)
|
||||
|
||||
purchase_id = fields.Many2one(
|
||||
comodel_name="purchase.order",
|
||||
related="purchase_line_id.order_id",
|
||||
|
@ -1,19 +1,21 @@
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
|
||||
# Copyright 2019 ForgeFlow S.L.
|
||||
# (https://www.forgeflow.com)
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo import api, models
|
||||
from odoo import models
|
||||
|
||||
|
||||
class PurchaseOrderLine(models.Model):
|
||||
_inherit = "purchase.order.line"
|
||||
|
||||
@api.multi
|
||||
def name_get(self):
|
||||
result = []
|
||||
orig_name = dict(super(PurchaseOrderLine, self).name_get())
|
||||
for line in self:
|
||||
name = orig_name[line.id]
|
||||
if self.env.context.get("po_line_info", False):
|
||||
name = "[{}] {} ({})".format(line.order_id.name, name, line.order_id.state)
|
||||
name = "[{}] {} ({})".format(
|
||||
line.order_id.name, name, line.order_id.state
|
||||
)
|
||||
result.append((line.id, name))
|
||||
return result
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Copyright 2017 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 import api, models
|
||||
@ -10,10 +10,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]["purchase_line_id"] = self.purchase_line_id.id
|
||||
|
@ -1 +1 @@
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
* Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
|
||||
|
@ -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/account-financial-tools/tree/12.0/account_move_line_purchase_info"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-12-0/account-financial-tools-12-0-account_move_line_purchase_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/92/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/account-financial-tools/tree/13.0/account_move_line_purchase_info"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-13-0/account-financial-tools-13-0-account_move_line_purchase_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/92/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module will add the purchase order line to journal items.</p>
|
||||
<p>The ultimate goal is to establish the purchase order line as one of the key
|
||||
fields to reconcile the Goods Received Not Invoiced accrual account.</p>
|
||||
@ -399,7 +399,7 @@ order line is copied to the account move line.</li>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/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/account-financial-tools/issues/new?body=module:%20account_move_line_purchase_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/account-financial-tools/issues/new?body=module:%20account_move_line_purchase_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">
|
||||
@ -407,13 +407,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Eficent</li>
|
||||
<li>ForgeFlow</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Jordi Ballester Alomar <<a class="reference external" href="mailto:jordi.ballester@eficent.com">jordi.ballester@eficent.com</a>></li>
|
||||
<li>Jordi Ballester Alomar <<a class="reference external" href="mailto:jordi.ballester@forgeflow.com">jordi.ballester@forgeflow.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
@ -423,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/account-financial-tools/tree/12.0/account_move_line_purchase_info">OCA/account-financial-tools</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/13.0/account_move_line_purchase_info">OCA/account-financial-tools</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,9 +1,9 @@
|
||||
# Copyright 2017 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 import fields
|
||||
from odoo.tests import common
|
||||
from odoo.tests import Form, common
|
||||
|
||||
|
||||
class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
||||
@ -11,12 +11,11 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
||||
super(TestAccountMoveLinePurchaseInfo, self).setUp()
|
||||
self.purchase_model = self.env["purchase.order"]
|
||||
self.purchase_line_model = self.env["purchase.order.line"]
|
||||
self.invoice_model = self.env["account.invoice"]
|
||||
self.invoice_line_model = self.env["account.invoice.line"]
|
||||
self.product_model = self.env["product.product"]
|
||||
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.am_model = self.env["account.move"]
|
||||
self.aml_model = self.env["account.move.line"]
|
||||
self.res_users_model = self.env["res.users"]
|
||||
|
||||
@ -78,7 +77,9 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
||||
return user.id
|
||||
|
||||
def _create_account_type(self, name, type):
|
||||
acc_type = self.acc_type_model.create({"name": name, "type": type})
|
||||
acc_type = self.acc_type_model.create(
|
||||
{"name": name, "type": type, "internal_group": name}
|
||||
)
|
||||
return acc_type
|
||||
|
||||
def _create_account(self, acc_type, name, code, company):
|
||||
@ -89,6 +90,7 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
||||
"code": code,
|
||||
"user_type_id": acc_type.id,
|
||||
"company_id": company.id,
|
||||
"reconcile": True,
|
||||
}
|
||||
)
|
||||
return account
|
||||
@ -189,18 +191,15 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
||||
expected_balance=expected_balance,
|
||||
)
|
||||
|
||||
invoice = self.invoice_model.create(
|
||||
{
|
||||
"partner_id": self.partner1.id,
|
||||
"purchase_id": purchase.id,
|
||||
"account_id": purchase.partner_id.property_account_payable_id.id,
|
||||
}
|
||||
)
|
||||
invoice.purchase_order_change()
|
||||
invoice.action_invoice_open()
|
||||
f = Form(self.am_model.with_context(default_type="in_invoice"))
|
||||
f.partner_id = purchase.partner_id
|
||||
f.purchase_id = purchase
|
||||
invoice = f.save()
|
||||
invoice.post()
|
||||
purchase.flush()
|
||||
|
||||
for aml in invoice.move_id.line_ids:
|
||||
if aml.product_id == po_line.product_id and aml.invoice_id:
|
||||
for aml in invoice.invoice_line_ids:
|
||||
if aml.product_id == po_line.product_id and aml.move_id:
|
||||
self.assertEqual(
|
||||
aml.purchase_line_id,
|
||||
po_line,
|
||||
|
@ -40,11 +40,11 @@
|
||||
<field name="purchase_line_id"
|
||||
groups="account_move_line_purchase_info.group_account_move_purchase_info"/>
|
||||
</field>
|
||||
<filter name="partner" position="after">
|
||||
<filter name="purchase_order" string="Purchase Order" domain="[]"
|
||||
<filter name="group_by_partner" position="after">
|
||||
<filter name="group_by_purchase_order" string="Purchase Order" domain="[]"
|
||||
context="{'group_by':'purchase_id'}"
|
||||
groups="account_move_line_purchase_info.group_account_move_purchase_info"/>
|
||||
<filter name="purchase_order_line" string="Purchase Order Line" domain="[]"
|
||||
<filter name="group_by_purchase_order_line" string="Purchase Order Line" domain="[]"
|
||||
context="{'group_by':'purchase_line_id','po_line_info':True}"
|
||||
groups="account_move_line_purchase_info.group_account_move_purchase_info"/>
|
||||
</filter>
|
||||
|
Loading…
Reference in New Issue
Block a user