Skip to content

Commit

Permalink
[MIG] account_invoice_margin: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdrubay committed Dec 22, 2023
1 parent b8b8394 commit c57b70c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions account_invoice_margin/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
3 changes: 2 additions & 1 deletion account_invoice_margin/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions account_invoice_margin/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
- Nedas Žilinskas
- [Factor Libre](https://factorlibre.com):
- Luis J. Salvatierra
- [Komit](https://komit-consulting.com):
- Jean-Charles Drubay
24 changes: 22 additions & 2 deletions account_invoice_margin/tests/test_account_invoice_margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c57b70c

Please sign in to comment.