[MIG] account_move_name_sequence: Migration to 15.0
This commit is contained in:
parent
3a1b342a62
commit
a800db0440
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Account Move Number Sequence",
|
"name": "Account Move Number Sequence",
|
||||||
"version": "14.0.1.2.2",
|
"version": "15.0.1.0.0",
|
||||||
"category": "Accounting",
|
"category": "Accounting",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"summary": "Generate journal entry number from sequence",
|
"summary": "Generate journal entry number from sequence",
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Copyright 2022 Vauxoo (https://www.vauxoo.com/)
|
# Copyright 2022 Vauxoo (https://www.vauxoo.com/)
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author: Moisés López <moylop260@vauxoo.com>
|
# @author: Moisés López <moylop260@vauxoo.com>
|
||||||
|
# @author: Francisco Luna <fluna@vauxoo.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -45,26 +46,26 @@ class AccountJournal(models.Model):
|
|||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_(
|
_(
|
||||||
"On journal '%s', the same sequence is used as "
|
"On journal '%s', the same sequence is used as "
|
||||||
"Entry Sequence and Credit Note Entry Sequence."
|
"Entry Sequence and Credit Note Entry Sequence.",
|
||||||
|
journal.display_name,
|
||||||
)
|
)
|
||||||
% journal.display_name
|
|
||||||
)
|
)
|
||||||
if journal.sequence_id and not journal.sequence_id.company_id:
|
if journal.sequence_id and not journal.sequence_id.company_id:
|
||||||
raise ValidationError(
|
msg = _(
|
||||||
_(
|
"The company is not set on sequence '%(sequence)s' configured on "
|
||||||
"The company is not set on sequence '%s' configured on "
|
"journal '%(journal)s'.",
|
||||||
"journal '%s'."
|
sequence=journal.sequence_id.display_name,
|
||||||
)
|
journal=journal.display_name,
|
||||||
% (journal.sequence_id.display_name, journal.display_name)
|
|
||||||
)
|
)
|
||||||
|
raise ValidationError(msg)
|
||||||
if journal.refund_sequence_id and not journal.refund_sequence_id.company_id:
|
if journal.refund_sequence_id and not journal.refund_sequence_id.company_id:
|
||||||
raise ValidationError(
|
msg = _(
|
||||||
_(
|
"The company is not set on sequence '%(sequence)s' configured as "
|
||||||
"The company is not set on sequence '%s' configured as "
|
"credit note sequence of journal '%(journal)s'.",
|
||||||
"credit note sequence of journal '%s'."
|
sequence=journal.refund_sequence_id.display_name,
|
||||||
)
|
journal=journal.display_name,
|
||||||
% (journal.refund_sequence_id.display_name, journal.display_name)
|
|
||||||
)
|
)
|
||||||
|
raise ValidationError(msg)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
@ -180,7 +181,10 @@ class AccountJournal(models.Model):
|
|||||||
)
|
)
|
||||||
select_max_number = (
|
select_max_number = (
|
||||||
"MAX(split_part(name, '%s', %d)::INTEGER) AS max_number"
|
"MAX(split_part(name, '%s', %d)::INTEGER) AS max_number"
|
||||||
% (prefixes[-1], prefixes.count(prefixes[-1]) + 1)
|
% (
|
||||||
|
prefixes[-1],
|
||||||
|
prefixes.count(prefixes[-1]) + 1,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
query = (
|
query = (
|
||||||
"SELECT %s, %s, %s FROM account_move "
|
"SELECT %s, %s, %s FROM account_move "
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
# Copyright 2022 Vauxoo (https://www.vauxoo.com/)
|
# Copyright 2022 Vauxoo (https://www.vauxoo.com/)
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author: Moisés López <moylop260@vauxoo.com>
|
# @author: Moisés López <moylop260@vauxoo.com>
|
||||||
|
# @author: Francisco Luna <fluna@vauxoo.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import SUPERUSER_ID, api
|
from odoo import SUPERUSER_ID, api
|
||||||
|
|
||||||
|
|
||||||
def create_journal_sequences(cr, registry):
|
def create_journal_sequences(cr, registry):
|
||||||
with api.Environment.manage():
|
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
journals = (
|
journals = (
|
||||||
env["account.journal"]
|
env["account.journal"]
|
||||||
|
Loading…
Reference in New Issue
Block a user