diff --git a/account_move_line_purchase_info/__manifest__.py b/account_move_line_purchase_info/__manifest__.py index 241c29b2..fbf6f109 100644 --- a/account_move_line_purchase_info/__manifest__.py +++ b/account_move_line_purchase_info/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Account Move Line Purchase Info", "summary": "Introduces the purchase order line to the journal items", - "version": "15.0.1.1.1", + "version": "16.0.1.0.0", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-financial-tools", "category": "Generic", diff --git a/account_move_line_purchase_info/models/stock_move.py b/account_move_line_purchase_info/models/stock_move.py index 5661133b..f5a48415 100644 --- a/account_move_line_purchase_info/models/stock_move.py +++ b/account_move_line_purchase_info/models/stock_move.py @@ -2,18 +2,17 @@ # (https://www.forgeflow.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import api, models +from odoo import models class StockMove(models.Model): _inherit = "stock.move" - @api.model def _prepare_account_move_line( - self, qty, cost, credit_account_id, debit_account_id, description + self, qty, cost, credit_account_id, debit_account_id, svl_id, description ): res = super(StockMove, self)._prepare_account_move_line( - qty, cost, credit_account_id, debit_account_id, description + qty, cost, credit_account_id, debit_account_id, svl_id, description ) for line in res: line[2]["purchase_line_id"] = self.purchase_line_id.id 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 2db0b4d6..8dc0a807 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 @@ -14,7 +14,6 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): cls.purchase_line_model = cls.env["purchase.order.line"] cls.product_model = cls.env["product.product"] cls.product_ctg_model = cls.env["product.category"] - cls.acc_type_model = cls.env["account.account.type"] cls.account_model = cls.env["account.account"] cls.am_model = cls.env["account.move"] cls.aml_model = cls.env["account.move.line"] @@ -28,18 +27,18 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): cls.group_account_manager = cls.env.ref("account.group_account_manager") # Create account for Goods Received Not Invoiced - acc_type = cls._create_account_type(cls, "equity", "other") + acc_type = "equity" name = "Goods Received Not Invoiced" code = "grni" cls.account_grni = cls._create_account(cls, acc_type, name, code, cls.company) # Create account for Cost of Goods Sold - acc_type = cls._create_account_type(cls, "expense", "other") + acc_type = "expense" name = "Cost of Goods Sold" code = "cogs" cls.account_cogs = cls._create_account(cls, acc_type, name, code, cls.company) # Create account for Inventory - acc_type = cls._create_account_type(cls, "asset", "other") + acc_type = "asset_current" name = "Inventory" code = "inventory" cls.account_inventory = cls._create_account( @@ -78,19 +77,13 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): ) return user.id - def _create_account_type(self, name, a_type): - acc_type = self.acc_type_model.create( - {"name": name, "type": a_type, "internal_group": name} - ) - return acc_type - def _create_account(self, acc_type, name, code, company): """Create an account.""" account = self.account_model.create( { "name": name, "code": code, - "user_type_id": acc_type.id, + "account_type": acc_type, "company_id": company.id, "reconcile": True, } @@ -183,7 +176,7 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): purchase.button_confirm() picking = purchase.picking_ids[0] picking.action_confirm() - picking.move_lines.write({"quantity_done": 1.0}) + picking.move_ids.write({"quantity_done": 1.0}) picking.button_validate() expected_balance = 1.0 @@ -193,12 +186,13 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): expected_balance=expected_balance, ) - f = Form(self.am_model.with_context(default_type="in_invoice")) + f = Form(self.am_model.with_context(default_move_type="in_invoice")) f.partner_id = purchase.partner_id - f.purchase_id = purchase + f.invoice_date = fields.Date().today() + f.purchase_vendor_bill_id = self.env["purchase.bill.union"].browse(-purchase.id) invoice = f.save() - invoice._post() - purchase.flush() + invoice.action_post() + purchase.flush_model() for aml in invoice.invoice_line_ids: if aml.product_id == po_line.product_id and aml.move_id: diff --git a/setup/account_move_line_purchase_info/odoo/addons/account_move_line_purchase_info b/setup/account_move_line_purchase_info/odoo/addons/account_move_line_purchase_info new file mode 120000 index 00000000..7192e04d --- /dev/null +++ b/setup/account_move_line_purchase_info/odoo/addons/account_move_line_purchase_info @@ -0,0 +1 @@ +../../../../account_move_line_purchase_info \ No newline at end of file diff --git a/setup/account_move_line_purchase_info/setup.py b/setup/account_move_line_purchase_info/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_move_line_purchase_info/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)