[REF] account_move_name_sequence: Use Odoo native methods + Typos
This commit is contained in:
parent
cdc7934b6d
commit
1653cc46c2
@ -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).
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -11,9 +12,11 @@
|
|||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"summary": "Generate journal entry number from sequence",
|
"summary": "Generate journal entry number from sequence",
|
||||||
"author": "Akretion,Vauxoo,Odoo Community Association (OCA)",
|
"author": "Akretion,Vauxoo,Odoo Community Association (OCA)",
|
||||||
"maintainers": ["alexis-via", "moylop260"],
|
"maintainers": ["alexis-via", "moylop260", "frahikLV"],
|
||||||
"website": "https://github.com/OCA/account-financial-tools",
|
"website": "https://github.com/OCA/account-financial-tools",
|
||||||
"depends": ["account"],
|
"depends": [
|
||||||
|
"account",
|
||||||
|
],
|
||||||
"data": [
|
"data": [
|
||||||
"views/account_journal.xml",
|
"views/account_journal.xml",
|
||||||
"views/account_move.xml",
|
"views/account_move.xml",
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta
|
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
@ -222,7 +220,7 @@ class AccountJournal(models.Model):
|
|||||||
year = "20" + year
|
year = "20" + year
|
||||||
if month:
|
if month:
|
||||||
date_from = fields.Date.to_date("%s-%s-1" % (year, month))
|
date_from = fields.Date.to_date("%s-%s-1" % (year, month))
|
||||||
date_to = date_from + relativedelta(day=31)
|
date_to = fields.Date.end_of(date_from, "month")
|
||||||
else:
|
else:
|
||||||
date_from = fields.Date.to_date("%s-1-1" % year)
|
date_from = fields.Date.to_date("%s-1-1" % year)
|
||||||
date_to = fields.Date.to_date("%s-12-31" % year)
|
date_to = fields.Date.to_date("%s-12-31" % year)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
from dateutil.relativedelta import relativedelta
|
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
@ -12,17 +10,18 @@ class IrSequence(models.Model):
|
|||||||
# TODO: Remove if odoo merge the following PR:
|
# TODO: Remove if odoo merge the following PR:
|
||||||
# https://github.com/odoo/odoo/pull/91019
|
# https://github.com/odoo/odoo/pull/91019
|
||||||
date_obj = fields.Date.from_string(date)
|
date_obj = fields.Date.from_string(date)
|
||||||
|
sequence_range = self.env["ir.sequence.date_range"]
|
||||||
prefix_suffix = "%s %s" % (self.prefix, self.suffix)
|
prefix_suffix = "%s %s" % (self.prefix, self.suffix)
|
||||||
if "%(range_day)s" in prefix_suffix:
|
if "%(range_day)s" in prefix_suffix:
|
||||||
date_from = date_obj
|
date_from = date_obj
|
||||||
date_to = date_obj
|
date_to = date_obj
|
||||||
elif "%(range_month)s" in prefix_suffix:
|
elif "%(range_month)s" in prefix_suffix:
|
||||||
date_from = date_obj + relativedelta(day=1)
|
date_from = fields.Date.start_of(date_obj, "month")
|
||||||
date_to = date_obj + relativedelta(day=31)
|
date_to = fields.Date.end_of(date_obj, "month")
|
||||||
else:
|
else:
|
||||||
date_from = date_obj + relativedelta(day=1, month=1)
|
date_from = fields.Date.start_of(date_obj, "year")
|
||||||
date_to = date_obj + relativedelta(day=31, month=12)
|
date_to = fields.Date.end_of(date_obj, "year")
|
||||||
date_range = self.env["ir.sequence.date_range"].search(
|
date_range = sequence_range.search(
|
||||||
[
|
[
|
||||||
("sequence_id", "=", self.id),
|
("sequence_id", "=", self.id),
|
||||||
("date_from", ">=", date),
|
("date_from", ">=", date),
|
||||||
@ -32,8 +31,8 @@ class IrSequence(models.Model):
|
|||||||
limit=1,
|
limit=1,
|
||||||
)
|
)
|
||||||
if date_range:
|
if date_range:
|
||||||
date_to = date_range.date_from + relativedelta(days=-1)
|
date_to = fields.Date.subtract(date_range.date_from, days=1)
|
||||||
date_range = self.env["ir.sequence.date_range"].search(
|
date_range = sequence_range.search(
|
||||||
[
|
[
|
||||||
("sequence_id", "=", self.id),
|
("sequence_id", "=", self.id),
|
||||||
("date_to", ">=", date_from),
|
("date_to", ">=", date_from),
|
||||||
@ -43,16 +42,11 @@ class IrSequence(models.Model):
|
|||||||
limit=1,
|
limit=1,
|
||||||
)
|
)
|
||||||
if date_range:
|
if date_range:
|
||||||
date_from = date_range.date_to + relativedelta(days=1)
|
date_to = fields.Date.add(date_range.date_to, days=1)
|
||||||
seq_date_range = (
|
sequence_range_vals = {
|
||||||
self.env["ir.sequence.date_range"]
|
"date_from": date_from,
|
||||||
.sudo()
|
"date_to": date_to,
|
||||||
.create(
|
"sequence_id": self.id,
|
||||||
{
|
}
|
||||||
"date_from": date_from,
|
seq_date_range = sequence_range.sudo().create(sequence_range_vals)
|
||||||
"date_to": date_to,
|
|
||||||
"sequence_id": self.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return seq_date_range
|
return seq_date_range
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
On the form view of an account journal, in the first tab, there is a many2one link to the sequence. When you create a new journal, you can keep this field empty and a new sequence will be automatically created when you save the journal.
|
On the form view of an account journal, in the first tab, there is a many2one link to the sequence. When you create a new journal, you can keep this field empty and a new sequence will be automatically created when you save the journal.
|
||||||
|
|
||||||
On sale and purchase journals, you have an additionnal option to have another sequence dedicated to refunds.
|
On sale and purchase journals, you have an additional option to have another sequence dedicated to refunds.
|
||||||
|
|
||||||
Upon module installation, all existing journals will be updated with a journal entry sequence (and also a credit note sequence for sale and purchase journals). You should update the configuration of the sequences to fit your needs. You can uncheck the option *Dedicated Credit Note Sequence* on existing sale and purchase journals if you don't want it. For the journals which already have journal entries, you should update the sequence configuration to avoid a discontinuity in the numbering for the next journal entry.
|
Upon module installation, all existing journals will be updated with a journal entry sequence (and also a credit note sequence for sale and purchase journals). You should update the configuration of the sequences to fit your needs. You can uncheck the option *Dedicated Credit Note Sequence* on existing sale and purchase journals if you don't want it. For the journals which already have journal entries, you should update the sequence configuration to avoid a discontinuity in the numbering for the next journal entry.
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
* Moisés López <moylop260@vauxoo.com>
|
* Moisés López <moylop260@vauxoo.com>
|
||||||
|
* Francisco Luna <fluna@vauxoo.com>
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright 2021 Akretion France (http://www.akretion.com/)
|
Copyright 2021 Akretion France (http://www.akretion.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: 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).
|
||||||
-->
|
-->
|
||||||
<odoo>
|
<odoo>
|
||||||
|
@ -10,23 +10,21 @@
|
|||||||
<field name="model">account.move</field>
|
<field name="model">account.move</field>
|
||||||
<field name="inherit_id" ref="account.view_move_form" />
|
<field name="inherit_id" ref="account.view_move_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath
|
<xpath
|
||||||
expr="//div[hasclass('oe_title')]/h1[hasclass('mt0')]"
|
expr="//div[hasclass('oe_title')]/h1[hasclass('mt0')]"
|
||||||
position="attributes"
|
position="attributes"
|
||||||
>
|
>
|
||||||
<attribute
|
<attribute name="attrs">{'invisible': [('name', '=', '/')]}</attribute>
|
||||||
name="attrs"
|
</xpath>
|
||||||
>{'invisible': [('name', '=', '/')]}</attribute>
|
<xpath
|
||||||
</xpath>
|
|
||||||
<xpath
|
|
||||||
expr="//div[hasclass('oe_title')]//field[@name='name']"
|
expr="//div[hasclass('oe_title')]//field[@name='name']"
|
||||||
position="attributes"
|
position="attributes"
|
||||||
>
|
>
|
||||||
<attribute name="attrs">{'readonly': 1}</attribute>
|
<attribute name="attrs">{'readonly': 1}</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='highest_name']/.." position="attributes">
|
<xpath expr="//field[@name='highest_name']/.." position="attributes">
|
||||||
<attribute name="attrs">{'invisible': 1}</attribute>
|
<attribute name="attrs">{'invisible': 1}</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user