2
0

[MIG] account_invoice_constraint_chronology: Migration to 14.0

This commit is contained in:
Alexey Pelykh 2021-04-06 20:41:36 +02:00 committed by Zina Rasoamanana
parent 8f231112b8
commit 3ac663af91
3 changed files with 5 additions and 19 deletions

View File

@ -3,7 +3,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"name": "Account Invoice Constraint Chronology", "name": "Account Invoice Constraint Chronology",
"version": "13.0.1.0.0", "version": "14.0.1.0.0",
"author": "Odoo Community Association (OCA), ACSONE SA/NV, CorporateHub", "author": "Odoo Community Association (OCA), ACSONE SA/NV, CorporateHub",
"website": "https://github.com/OCA/account-financial-tools", "website": "https://github.com/OCA/account-financial-tools",
"license": "AGPL-3", "license": "AGPL-3",

View File

@ -15,13 +15,10 @@ class AccountMove(models.Model):
self.ensure_one() self.ensure_one()
domain = [ domain = [
("journal_id", "=", self.journal_id.id), ("journal_id", "=", self.journal_id.id),
("type", "!=", "entry"), ("move_type", "!=", "entry"),
] ]
if ( if self.journal_id.refund_sequence:
self.journal_id.refund_sequence domain.append(("move_type", "=", self.move_type))
and self.journal_id.sequence_id != self.journal_id.refund_sequence_id
):
domain.append(("type", "=", self.type))
return domain return domain
def _get_older_conflicting_invoices_domain(self): def _get_older_conflicting_invoices_domain(self):

View File

@ -20,23 +20,12 @@ class TestAccountInvoiceConstraintChronology(common.SavepointCase):
cls.yesterday = cls.today - timedelta(days=1) cls.yesterday = cls.today - timedelta(days=1)
cls.tomorrow = cls.today + timedelta(days=1) cls.tomorrow = cls.today + timedelta(days=1)
cls.IrSequence = cls.env["ir.sequence"]
cls.sale_journal_sequence = cls.IrSequence.create(
{
"name": "Sale journal sequence",
"prefix": "SALE",
"padding": 6,
"company_id": cls.company.id,
}
)
cls.AccountJournal = cls.env["account.journal"] cls.AccountJournal = cls.env["account.journal"]
cls.sale_journal = cls.AccountJournal.create( cls.sale_journal = cls.AccountJournal.create(
{ {
"name": "Sale journal", "name": "Sale journal",
"code": "SALE", "code": "SALE",
"type": "sale", "type": "sale",
"sequence_id": cls.sale_journal_sequence.id,
"check_chronology": True, "check_chronology": True,
} }
) )
@ -46,7 +35,7 @@ class TestAccountInvoiceConstraintChronology(common.SavepointCase):
cls.AccountMove = cls.env["account.move"] cls.AccountMove = cls.env["account.move"]
with common.Form( with common.Form(
cls.AccountMove.with_context(default_type="out_invoice") cls.AccountMove.with_context(default_move_type="out_invoice")
) as invoice_form: ) as invoice_form:
invoice_form.invoice_date = cls.today invoice_form.invoice_date = cls.today
invoice_form.partner_id = cls.partner_2 invoice_form.partner_id = cls.partner_2