diff --git a/account_move_line_purchase_info/README.rst b/account_move_line_purchase_info/README.rst index a6563c05..dce3ff95 100644 --- a/account_move_line_purchase_info/README.rst +++ b/account_move_line_purchase_info/README.rst @@ -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 `_. 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 `_. +`feedback `_. 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 Alomar 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 `_ project on GitHub. +This module is part of the `OCA/account-financial-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_move_line_purchase_info/__manifest__.py b/account_move_line_purchase_info/__manifest__.py index 295bbbcf..22f1b185 100644 --- a/account_move_line_purchase_info/__manifest__.py +++ b/account_move_line_purchase_info/__manifest__.py @@ -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"], diff --git a/account_move_line_purchase_info/migrations/12.0.2.0.0/pre-migration.py b/account_move_line_purchase_info/migrations/12.0.2.0.0/pre-migration.py deleted file mode 100644 index b3f80199..00000000 --- a/account_move_line_purchase_info/migrations/12.0.2.0.0/pre-migration.py +++ /dev/null @@ -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) diff --git a/account_move_line_purchase_info/models/__init__.py b/account_move_line_purchase_info/models/__init__.py index a8322b5f..7e113f90 100644 --- a/account_move_line_purchase_info/models/__init__.py +++ b/account_move_line_purchase_info/models/__init__.py @@ -1,4 +1,3 @@ from . import account_move -from . import account_invoice from . import purchase_order_line from . import stock_move diff --git a/account_move_line_purchase_info/models/account_invoice.py b/account_move_line_purchase_info/models/account_invoice.py deleted file mode 100644 index 5fd96ac0..00000000 --- a/account_move_line_purchase_info/models/account_invoice.py +++ /dev/null @@ -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 diff --git a/account_move_line_purchase_info/models/account_move.py b/account_move_line_purchase_info/models/account_move.py index 282b1108..b5a717ef 100644 --- a/account_move_line_purchase_info/models/account_move.py +++ b/account_move_line_purchase_info/models/account_move.py @@ -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", diff --git a/account_move_line_purchase_info/models/purchase_order_line.py b/account_move_line_purchase_info/models/purchase_order_line.py index 6019faef..2fe54b9d 100644 --- a/account_move_line_purchase_info/models/purchase_order_line.py +++ b/account_move_line_purchase_info/models/purchase_order_line.py @@ -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 diff --git a/account_move_line_purchase_info/models/stock_move.py b/account_move_line_purchase_info/models/stock_move.py index f306cedc..5661133b 100644 --- a/account_move_line_purchase_info/models/stock_move.py +++ b/account_move_line_purchase_info/models/stock_move.py @@ -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 diff --git a/account_move_line_purchase_info/readme/CONTRIBUTORS.rst b/account_move_line_purchase_info/readme/CONTRIBUTORS.rst index 6860affe..c84e2e8e 100644 --- a/account_move_line_purchase_info/readme/CONTRIBUTORS.rst +++ b/account_move_line_purchase_info/readme/CONTRIBUTORS.rst @@ -1 +1 @@ -* Jordi Ballester Alomar +* Jordi Ballester Alomar diff --git a/account_move_line_purchase_info/static/description/index.html b/account_move_line_purchase_info/static/description/index.html index 1932e350..6de93dca 100644 --- a/account_move_line_purchase_info/static/description/index.html +++ b/account_move_line_purchase_info/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

This module will add the purchase order line to journal items.

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.

@@ -399,7 +399,7 @@ order line is copied to the account move line.

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -407,13 +407,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Authors

    -
  • Eficent
  • +
  • ForgeFlow

Contributors

@@ -423,7 +423,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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 project on GitHub.

+

This module is part of the OCA/account-financial-tools project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/account_move_line_purchase_info/tests/test_account_move_line_purchase_info.py b/account_move_line_purchase_info/tests/test_account_move_line_purchase_info.py index d56ab2c7..1275b107 100644 --- a/account_move_line_purchase_info/tests/test_account_move_line_purchase_info.py +++ b/account_move_line_purchase_info/tests/test_account_move_line_purchase_info.py @@ -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, diff --git a/account_move_line_purchase_info/views/account_move_view.xml b/account_move_line_purchase_info/views/account_move_view.xml index c5ab8bb1..6a0d0bc1 100644 --- a/account_move_line_purchase_info/views/account_move_view.xml +++ b/account_move_line_purchase_info/views/account_move_view.xml @@ -40,11 +40,11 @@ - - + -