diff --git a/account_invoice_margin/__manifest__.py b/account_invoice_margin/__manifest__.py index c0d03433..06761bd4 100644 --- a/account_invoice_margin/__manifest__.py +++ b/account_invoice_margin/__manifest__.py @@ -4,10 +4,10 @@ { "name": "Account Invoice Margin", "summary": "Show margin in invoices", - "version": "16.0.1.0.1", + "version": "17.0.1.0.0", "category": "Account", "website": "https://github.com/OCA/margin-analysis", - "author": "Tecnativa, " "GRAP, " "Odoo Community Association (OCA)", + "author": "Tecnativa, GRAP, Odoo Community Association (OCA)", "license": "AGPL-3", "development_status": "Production/Stable", "maintainers": ["sergio-teruel"], diff --git a/account_invoice_margin/hooks.py b/account_invoice_margin/hooks.py index 4c50a742..9259e3c6 100644 --- a/account_invoice_margin/hooks.py +++ b/account_invoice_margin/hooks.py @@ -15,7 +15,8 @@ ) -def pre_init_hook(cr): +def pre_init_hook(env): + cr = env.cr for table, column in COLUMNS: if not column_exists(cr, table, column): _logger.info("Create column %s in database", column) diff --git a/account_invoice_margin/readme/CONTRIBUTORS.md b/account_invoice_margin/readme/CONTRIBUTORS.md index e36d6f6a..4f5a116f 100644 --- a/account_invoice_margin/readme/CONTRIBUTORS.md +++ b/account_invoice_margin/readme/CONTRIBUTORS.md @@ -8,3 +8,5 @@ - Nedas Žilinskas - [Factor Libre](https://factorlibre.com): - Luis J. Salvatierra +- [Komit](https://komit-consulting.com): + - Jean-Charles Drubay diff --git a/account_invoice_margin/tests/test_account_invoice_margin.py b/account_invoice_margin/tests/test_account_invoice_margin.py index 01e34171..9b910083 100644 --- a/account_invoice_margin/tests/test_account_invoice_margin.py +++ b/account_invoice_margin/tests/test_account_invoice_margin.py @@ -61,17 +61,37 @@ def test_invoice_refund(self): ) .create( { - "refund_method": "refund", "reason": "reason test create", "journal_id": self.invoice.journal_id.id, } ) ) - action = wiz.reverse_moves() + action = wiz.refund_moves() new_invoice = self.env["account.move"].browse(action["res_id"]) self.assertEqual(new_invoice.invoice_line_ids.margin, 1000.00) self.assertEqual(new_invoice.invoice_line_ids.margin_signed, -1000.00) + def test_invoice_modify_moves(self): + self.invoice.action_post() + wiz = ( + self.env["account.move.reversal"] + .with_context( + active_model="account.move", + active_ids=self.invoice.ids, + active_id=self.invoice.id, + ) + .create( + { + "reason": "reason test create", + "journal_id": self.invoice.journal_id.id, + } + ) + ) + action = wiz.modify_moves() + new_invoice = self.env["account.move"].browse(action["res_id"]) + self.assertEqual(new_invoice.invoice_line_ids.margin, 1000.00) + self.assertEqual(new_invoice.invoice_line_ids.margin_signed, 1000.00) + def test_invoice_different_currency(self): company = self.env.company currency = self.env["res.currency"].create(