From c5faa0f7c69d96dbff739ff48a666e6690847323 Mon Sep 17 00:00:00 2001 From: "matteo.tognini" Date: Mon, 14 Oct 2024 12:00:27 +0200 Subject: [PATCH] [MIG]l10n_it_riba_sale_commission: Migration to v16 --- l10n_it_riba_sale_commission/__manifest__.py | 4 +- .../tests/test_riba_sale_commission.py | 94 ++++++++----------- .../views/configuration_riba_view.xml | 5 +- .../wizard/wizard_riba_commissions_settle.py | 6 +- 4 files changed, 47 insertions(+), 62 deletions(-) diff --git a/l10n_it_riba_sale_commission/__manifest__.py b/l10n_it_riba_sale_commission/__manifest__.py index 8dbfb760761a..f3720a67b5d5 100644 --- a/l10n_it_riba_sale_commission/__manifest__.py +++ b/l10n_it_riba_sale_commission/__manifest__.py @@ -2,7 +2,7 @@ { "name": "ITA - Integrazione tra RiBa e provvigioni su vendite", "summary": "Modulo ponte tra provvigioni agenti e RiBa", - "version": "14.0.1.1.0", + "version": "16.0.1.0.0", "development_status": "Alpha", "category": "Localization/Italy", "website": "https://github.com/OCA/l10n-italy", @@ -13,7 +13,7 @@ "installable": True, "depends": [ "sale_commission", - "l10n_it_ricevute_bancarie", + "l10n_it_riba", ], "data": [ "views/invoice_no_commission.xml", diff --git a/l10n_it_riba_sale_commission/tests/test_riba_sale_commission.py b/l10n_it_riba_sale_commission/tests/test_riba_sale_commission.py index a80df7fbd9fe..1e9974a88d8b 100644 --- a/l10n_it_riba_sale_commission/tests/test_riba_sale_commission.py +++ b/l10n_it_riba_sale_commission/tests/test_riba_sale_commission.py @@ -1,20 +1,19 @@ # Copyright 2023 Nextev # License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html -from datetime import datetime from dateutil.relativedelta import relativedelta from odoo import fields -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestRibaCommission(SavepointCase): +class TestRibaCommission(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.distinta_model = cls.env["riba.distinta"] - cls.commission_model = cls.env["sale.commission"] + cls.distinta_model = cls.env["riba.slip"] + cls.commission_model = cls.env["commission"] cls.account_model = cls.env["account.account"] cls.move_line_model = cls.env["account.move.line"] @@ -40,10 +39,11 @@ def setUpClass(cls): cls.sale_account = cls.env["account.account"].search( [ ( - "user_type_id", + "account_type", "=", - cls.env.ref("account.data_account_type_revenue").id, - ) + "income_other", + ), + ("company_id", "=", cls.env.company.id), ], limit=1, ) @@ -54,72 +54,69 @@ def setUpClass(cls): cls.expenses_account = cls.env["account.account"].search( [ ( - "user_type_id", + "account_type", "=", - cls.env.ref("account.data_account_type_expenses").id, - ) + "expense", + ), + ("company_id", "=", cls.env.company.id), ], limit=1, ) cls.bank_account = cls.env["account.account"].search( [ ( - "user_type_id", + "account_type", "=", - cls.env.ref("account.data_account_type_liquidity").id, - ) + "asset_cash", + ), + ("company_id", "=", cls.env.company.id), ], limit=1, ) - cls.account_user_type = cls.env.ref("account.data_account_type_receivable") cls.unsolved_account = cls.env["account.account"].create( { - "code": "Past Due", + "code": "PastDue", "name": "Past Due Bills Account (test)", "reconcile": True, - "user_type_id": cls.account_user_type.id, + "account_type": "asset_receivable", } ) cls.account_rec1_id = cls.account_model.create( dict( - code="cust_acc", + code="custacc", name="customer account", - user_type_id=cls.account_user_type.id, + account_type="asset_receivable", reconcile=True, ) ) - cls.account_asset_user_type = cls.env.ref( - "account.data_account_type_fixed_assets" - ) cls.sbf_effects = cls.env["account.account"].create( { "code": "STC", "name": "STC Bills (test)", "reconcile": True, - "user_type_id": cls.account_user_type.id, + "account_type": "asset_receivable", } ) cls.riba_account = cls.env["account.account"].create( { - "code": "C/O", - "name": "C/O Account (test)", - "user_type_id": cls.account_asset_user_type.id, + "code": "RiBa", + "name": "RiBa Account (test)", + "account_type": "asset_fixed", } ) - cls.company_bank = cls.env.ref("l10n_it_ricevute_bancarie.company_bank") + cls.company_bank = cls.env.ref("l10n_it_riba.company_bank") cls.riba_config = cls.env["riba.configuration"].create( { "name": "Subject To Collection", "type": "sbf", - "safety_days": 5, "bank_id": cls.company_bank.id, "acceptance_journal_id": cls.bank_journal.id, - "accreditation_journal_id": cls.bank_journal.id, + "credit_journal_id": cls.bank_journal.id, "acceptance_account_id": cls.sbf_effects.id, - "accreditation_account_id": cls.riba_account.id, + "credit_account_id": cls.riba_account.id, "bank_account_id": cls.bank_account.id, "bank_expense_account_id": cls.expenses_account.id, - "unsolved_journal_id": cls.bank_journal.id, + "past_due_journal_id": cls.bank_journal.id, "overdue_effects_account_id": cls.unsolved_account.id, "protest_charge_account_id": cls.expenses_account.id, } @@ -130,9 +127,9 @@ def setUpClass(cls): cls.partner.write({"agent": False}) cls.sale_order_model = cls.env["sale.order"] cls.advance_inv_model = cls.env["sale.advance.payment.inv"] - cls.settle_model = cls.env["sale.commission.settlement"] - cls.make_settle_model = cls.env["sale.commission.make.settle"] - cls.make_inv_model = cls.env["sale.commission.make.invoice"] + cls.settle_model = cls.env["commission.settlement"] + cls.make_settle_model = cls.env["commission.make.settle"] + cls.make_inv_model = cls.env["commission.make.invoice"] cls.product = cls.env.ref("product.product_product_5") cls.product.list_price = 5 # for testing specific commission section cls.commission_product = cls.env["product.product"].create( @@ -153,13 +150,6 @@ def setUpClass(cls): } ) - cls.income_account = cls.env["account.account"].search( - [ - ("company_id", "=", cls.company.id), - ("user_type_id.name", "=", "Income"), - ], - limit=1, - ) cls.payment_term = cls._create_riba_pterm(cls) cls.env["res.partner.bank"].create( { @@ -217,7 +207,7 @@ def _create_riba_pterm(self): 0, { "value": "balance", - "option": "day_following_month", + "months": 1, "days": 1, }, ) @@ -225,7 +215,7 @@ def _create_riba_pterm(self): } ) - def _settle_agent(self, agent=None, period=None, date=None, date_payment_to=None): + def _settle_agent(self, agent=None, period=None, date=None): vals = { "date_to": ( fields.Datetime.from_string(fields.Datetime.now()) @@ -233,7 +223,7 @@ def _settle_agent(self, agent=None, period=None, date=None, date_payment_to=None ) if period else date, - "date_payment_to": date_payment_to, + "settlement_type": "sale_invoice", } if agent: vals["agent_ids"] = [(4, agent.id)] @@ -252,20 +242,18 @@ def register_payment(self, invoice): if move_line.account_id.id == self.account_rec1_id.id: riba_move_line_id = move_line.id action = wizard_riba_issue.with_context( - {"active_ids": [riba_move_line_id]} + active_ids=[riba_move_line_id] ).create_list() riba_list_id = action and action["res_id"] or False riba_list = self.distinta_model.browse(riba_list_id) riba_list.confirm() riba_list._compute_acceptance_move_ids() wiz_accreditation = ( - self.env["riba.accreditation"] + self.env["riba.credit"] .with_context( - { - "active_model": "riba.distinta", - "active_ids": [riba_list_id], - "active_id": riba_list_id, - } + active_model="riba.slip", + active_ids=[riba_list_id], + active_id=riba_list_id, ) .create( { @@ -281,8 +269,8 @@ def test_riba_settlement(self): self.register_payment(invoice) invoice_not_settle = self._create_invoice(date - relativedelta(days=4)) self.register_payment(invoice_not_settle) - self._settle_agent(self.agent_monthly, 1, date_payment_to=datetime.now()) - settlements = self.env["sale.commission.settlement"].search( + self._settle_agent(self.agent_monthly, 1) + settlements = self.env["commission.settlement"].search( [ ( "agent_id", diff --git a/l10n_it_riba_sale_commission/views/configuration_riba_view.xml b/l10n_it_riba_sale_commission/views/configuration_riba_view.xml index f7d30239143a..699b9e20ffd0 100644 --- a/l10n_it_riba_sale_commission/views/configuration_riba_view.xml +++ b/l10n_it_riba_sale_commission/views/configuration_riba_view.xml @@ -3,10 +3,7 @@ riba.conf.form.safety.days riba.configuration - +