mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[MIG] account_mass_reconcile: Migration to 17.0
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
"name": "Account Mass Reconcile",
|
||||
"version": "16.0.1.1.1",
|
||||
"version": "17.0.1.0.0",
|
||||
"depends": ["account"],
|
||||
"author": "Akretion,Camptocamp,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/account-reconcile",
|
||||
|
||||
@@ -158,9 +158,9 @@ class MassReconcileAdvanced(models.AbstractModel):
|
||||
"A matcher %(mkey)s is compared with a matcher %(omkey)s, the _matchers and "
|
||||
"_opposite_matchers are probably wrong"
|
||||
) % {"mkey": mkey, "omkey": omkey}
|
||||
if not isinstance(mvalue, (list, tuple)):
|
||||
if not isinstance(mvalue, list | tuple):
|
||||
mvalue = (mvalue,)
|
||||
if not isinstance(omvalue, (list, tuple)):
|
||||
if not isinstance(omvalue, list | tuple):
|
||||
omvalue = (omvalue,)
|
||||
return MassReconcileAdvanced._compare_matcher_values(mkey, mvalue, omvalue)
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ class MassReconcileBase(models.AbstractModel):
|
||||
)
|
||||
move.action_post()
|
||||
return move.line_ids.filtered(
|
||||
lambda l: l.account_id.id == counterpart_account.id
|
||||
lambda line: line.account_id.id == counterpart_account.id
|
||||
)
|
||||
|
||||
def _reconcile_lines(self, lines, allow_partial=False):
|
||||
|
||||
@@ -7,7 +7,7 @@ from odoo.tests import common
|
||||
class TestOnChange(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestOnChange, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
acc_setting = cls.env["res.config.settings"]
|
||||
cls.acc_setting_obj = acc_setting.create({})
|
||||
cls.company_obj = cls.env["res.company"]
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
import odoo.tests
|
||||
from odoo import exceptions, fields
|
||||
|
||||
from odoo.addons.account.tests.common import TestAccountReconciliationCommon
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
|
||||
|
||||
@odoo.tests.tagged("post_install", "-at_install")
|
||||
class TestReconcile(TestAccountReconciliationCommon):
|
||||
class TestReconcile(AccountTestInvoicingCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestReconcile, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
cls.rec_history_obj = cls.env["mass.reconcile.history"]
|
||||
cls.mass_rec_obj = cls.env["account.mass.reconcile"]
|
||||
cls.mass_rec_method_obj = cls.env["account.mass.reconcile.method"]
|
||||
|
||||
@@ -7,14 +7,14 @@ from datetime import date, timedelta
|
||||
import odoo.tests
|
||||
from odoo import fields
|
||||
|
||||
from odoo.addons.account.tests.common import TestAccountReconciliationCommon
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
|
||||
|
||||
@odoo.tests.tagged("post_install", "-at_install")
|
||||
class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
class TestScenarioReconcile(AccountTestInvoicingCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestScenarioReconcile, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
cls.rec_history_obj = cls.env["mass.reconcile.history"]
|
||||
cls.mass_rec_obj = cls.env["account.mass.reconcile"]
|
||||
cls.invoice_obj = cls.env["account.move"]
|
||||
@@ -39,7 +39,11 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
acs_ids = cls.acs_model.create(default_vals)
|
||||
|
||||
def test_scenario_reconcile(self):
|
||||
invoice = self.create_invoice()
|
||||
invoice = self.init_invoice(
|
||||
move_type="out_invoice",
|
||||
amounts=[50],
|
||||
post=True,
|
||||
)
|
||||
self.assertEqual("posted", invoice.state)
|
||||
|
||||
receivalble_account_id = invoice.partner_id.property_account_receivable_id.id
|
||||
@@ -69,7 +73,11 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
self.assertEqual("paid", invoice.payment_state)
|
||||
|
||||
def test_scenario_reconcile_newest(self):
|
||||
invoice = self.create_invoice()
|
||||
invoice = self.init_invoice(
|
||||
move_type="out_invoice",
|
||||
amounts=[50],
|
||||
post=True,
|
||||
)
|
||||
self.assertEqual("posted", invoice.state)
|
||||
|
||||
receivalble_account_id = invoice.partner_id.property_account_receivable_id.id
|
||||
@@ -120,15 +128,23 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
mass_rec.run_reconcile()
|
||||
self.assertEqual("paid", invoice.payment_state)
|
||||
self.assertTrue(mass_rec.last_history)
|
||||
payment_new_line = payment_new.move_id.line_ids.filtered(lambda l: l.credit)
|
||||
payment_old_line = payment_old.move_id.line_ids.filtered(lambda l: l.credit)
|
||||
payment_new_line = payment_new.move_id.line_ids.filtered(
|
||||
lambda line: line.credit
|
||||
)
|
||||
payment_old_line = payment_old.move_id.line_ids.filtered(
|
||||
lambda line: line.credit
|
||||
)
|
||||
self.assertTrue(payment_new_line in mass_rec.last_history.reconcile_line_ids)
|
||||
self.assertTrue(payment_new_line.reconciled)
|
||||
self.assertFalse(payment_old_line in mass_rec.last_history.reconcile_line_ids)
|
||||
self.assertFalse(payment_old_line.reconciled)
|
||||
|
||||
def test_scenario_reconcile_oldest(self):
|
||||
invoice = self.create_invoice()
|
||||
invoice = self.init_invoice(
|
||||
move_type="out_invoice",
|
||||
amounts=[50],
|
||||
post=True,
|
||||
)
|
||||
self.assertEqual("posted", invoice.state)
|
||||
|
||||
receivalble_account_id = invoice.partner_id.property_account_receivable_id.id
|
||||
@@ -179,8 +195,12 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
mass_rec.run_reconcile()
|
||||
self.assertEqual("paid", invoice.payment_state)
|
||||
self.assertTrue(mass_rec.last_history)
|
||||
payment_new_line = payment_new.move_id.line_ids.filtered(lambda l: l.credit)
|
||||
payment_old_line = payment_old.move_id.line_ids.filtered(lambda l: l.credit)
|
||||
payment_new_line = payment_new.move_id.line_ids.filtered(
|
||||
lambda line: line.credit
|
||||
)
|
||||
payment_old_line = payment_old.move_id.line_ids.filtered(
|
||||
lambda line: line.credit
|
||||
)
|
||||
self.assertFalse(payment_new_line in mass_rec.last_history.reconcile_line_ids)
|
||||
self.assertFalse(payment_new_line.reconciled)
|
||||
self.assertTrue(payment_old_line in mass_rec.last_history.reconcile_line_ids)
|
||||
@@ -211,10 +231,12 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
currency_rate = fields.first(currency_rate)
|
||||
currency_rate.rate = 1.5
|
||||
# create invoice
|
||||
invoice = self._create_invoice(
|
||||
currency_id=self.ref("base.USD"),
|
||||
date_invoice=fields.Date.today(),
|
||||
auto_validate=True,
|
||||
invoice = self.init_invoice(
|
||||
move_type="out_invoice",
|
||||
currency=self.env.ref("base.USD"),
|
||||
amounts=[50],
|
||||
invoice_date=fields.Date.today(),
|
||||
post=True,
|
||||
)
|
||||
self.assertEqual("posted", invoice.state)
|
||||
|
||||
@@ -254,7 +276,11 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
self.assertEqual("paid", invoice.payment_state)
|
||||
|
||||
def test_scenario_reconcile_partial(self):
|
||||
invoice1 = self.create_invoice()
|
||||
invoice1 = self.init_invoice(
|
||||
move_type="out_invoice",
|
||||
amounts=[50],
|
||||
post=True,
|
||||
)
|
||||
invoice1.ref = "test ref"
|
||||
# create payment
|
||||
receivable_account_id = invoice1.partner_id.property_account_receivable_id.id
|
||||
@@ -271,11 +297,11 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
)
|
||||
payment.action_post()
|
||||
line_payment = payment.line_ids.filtered(
|
||||
lambda l: l.account_id.id == receivable_account_id
|
||||
lambda line: line.account_id.id == receivable_account_id
|
||||
)
|
||||
self.assertEqual(line_payment.reconciled, False)
|
||||
invoice1_line = invoice1.line_ids.filtered(
|
||||
lambda l: l.account_id.id == receivable_account_id
|
||||
lambda line: line.account_id.id == receivable_account_id
|
||||
)
|
||||
self.assertEqual(invoice1_line.reconciled, False)
|
||||
|
||||
@@ -295,10 +321,10 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
|
||||
self.assertEqual(line_payment.amount_residual, -450.0)
|
||||
self.assertEqual(invoice1_line.reconciled, True)
|
||||
invoice2 = self._create_invoice(invoice_amount=500, auto_validate=True)
|
||||
invoice2 = self.init_invoice(move_type="out_invoice", amounts=[500], post=True)
|
||||
invoice2.ref = "test ref"
|
||||
invoice2_line = invoice2.line_ids.filtered(
|
||||
lambda l: l.account_id.id == receivable_account_id
|
||||
lambda line: line.account_id.id == receivable_account_id
|
||||
)
|
||||
mass_rec.run_reconcile()
|
||||
self.assertEqual(line_payment.reconciled, True)
|
||||
@@ -307,7 +333,11 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
self.assertEqual(invoice2_line.amount_residual, 50.0)
|
||||
|
||||
def test_reconcile_with_writeoff(self):
|
||||
invoice = self.create_invoice()
|
||||
invoice = self.init_invoice(
|
||||
move_type="out_invoice",
|
||||
amounts=[50],
|
||||
post=True,
|
||||
)
|
||||
|
||||
receivable_account_id = invoice.partner_id.property_account_receivable_id.id
|
||||
# create payment
|
||||
@@ -355,7 +385,7 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
self.assertEqual("paid", invoice.payment_state)
|
||||
full_reconcile = invoice.line_ids.mapped("full_reconcile_id")
|
||||
writeoff_line = full_reconcile.reconciled_line_ids.filtered(
|
||||
lambda l: l.debit == 0.1
|
||||
lambda line: line.debit == 0.1
|
||||
)
|
||||
self.assertEqual(len(writeoff_line), 1)
|
||||
self.assertEqual(
|
||||
@@ -365,11 +395,11 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
|
||||
def test_reconcile_with_writeoff_today(self):
|
||||
yesterday = date.today() - timedelta(days=1)
|
||||
invoice = self._create_invoice(
|
||||
invoice = self.init_invoice(
|
||||
move_type="out_invoice",
|
||||
invoice_amount=50,
|
||||
date_invoice=yesterday,
|
||||
auto_validate=True,
|
||||
amounts=[50],
|
||||
invoice_date=yesterday,
|
||||
post=True,
|
||||
)
|
||||
|
||||
receivable_account_id = invoice.partner_id.property_account_receivable_id.id
|
||||
@@ -417,7 +447,7 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
|
||||
self.assertEqual("paid", invoice.payment_state)
|
||||
full_reconcile = invoice.line_ids.mapped("full_reconcile_id")
|
||||
writeoff_line = full_reconcile.reconciled_line_ids.filtered(
|
||||
lambda l: l.debit == 0.02
|
||||
lambda line: line.debit == 0.02
|
||||
)
|
||||
self.assertEqual(len(writeoff_line), 1)
|
||||
self.assertEqual(writeoff_line.date, fields.Date.today())
|
||||
|
||||
@@ -165,15 +165,9 @@ The lines should have the same partner, and the credit entry ref. is matched wit
|
||||
<field name="sequence" widget="handle" />
|
||||
<field name="name" />
|
||||
<field name="write_off" />
|
||||
<field
|
||||
name="account_lost_id"
|
||||
attrs="{'required':[('write_off','>',0)]}"
|
||||
/>
|
||||
<field
|
||||
name="account_profit_id"
|
||||
attrs="{'required':[('write_off','>',0)]}"
|
||||
/>
|
||||
<field name="journal_id" attrs="{'required':[('write_off','>',0)]}" />
|
||||
<field name="account_lost_id" required="write_off > 0" />
|
||||
<field name="account_profit_id" required="write_off > 0" />
|
||||
<field name="journal_id" required="write_off > 0" />
|
||||
<field name="date_base_on" />
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="account.res_config_settings_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@id='invoicing_settings']" position="after">
|
||||
<xpath expr="//block[@id='invoicing_settings']" position="after">
|
||||
<h2>Reconciliation</h2>
|
||||
<div class="row mt16 o_settings_container" id="reconciliation_settings">
|
||||
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||
|
||||
Reference in New Issue
Block a user