2
0

[REF] account_move_name_sequence: Use Odoo native methods + Typos

This commit is contained in:
Francisco Javier Luna Vazquez 2022-05-26 09:26:12 -05:00 committed by Rodrigo
parent cdc7934b6d
commit 1653cc46c2
7 changed files with 33 additions and 37 deletions

View File

@ -2,6 +2,7 @@
# Copyright 2022 Vauxoo (https://www.vauxoo.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).
{
@ -11,9 +12,11 @@
"license": "AGPL-3",
"summary": "Generate journal entry number from sequence",
"author": "Akretion,Vauxoo,Odoo Community Association (OCA)",
"maintainers": ["alexis-via", "moylop260"],
"maintainers": ["alexis-via", "moylop260", "frahikLV"],
"website": "https://github.com/OCA/account-financial-tools",
"depends": ["account"],
"depends": [
"account",
],
"data": [
"views/account_journal.xml",
"views/account_move.xml",

View File

@ -6,8 +6,6 @@
import logging
from dateutil.relativedelta import relativedelta
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
@ -222,7 +220,7 @@ class AccountJournal(models.Model):
year = "20" + year
if 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:
date_from = fields.Date.to_date("%s-1-1" % year)
date_to = fields.Date.to_date("%s-12-31" % year)

View File

@ -1,5 +1,3 @@
from dateutil.relativedelta import relativedelta
from odoo import fields, models
@ -12,17 +10,18 @@ class IrSequence(models.Model):
# TODO: Remove if odoo merge the following PR:
# https://github.com/odoo/odoo/pull/91019
date_obj = fields.Date.from_string(date)
sequence_range = self.env["ir.sequence.date_range"]
prefix_suffix = "%s %s" % (self.prefix, self.suffix)
if "%(range_day)s" in prefix_suffix:
date_from = date_obj
date_to = date_obj
elif "%(range_month)s" in prefix_suffix:
date_from = date_obj + relativedelta(day=1)
date_to = date_obj + relativedelta(day=31)
date_from = fields.Date.start_of(date_obj, "month")
date_to = fields.Date.end_of(date_obj, "month")
else:
date_from = date_obj + relativedelta(day=1, month=1)
date_to = date_obj + relativedelta(day=31, month=12)
date_range = self.env["ir.sequence.date_range"].search(
date_from = fields.Date.start_of(date_obj, "year")
date_to = fields.Date.end_of(date_obj, "year")
date_range = sequence_range.search(
[
("sequence_id", "=", self.id),
("date_from", ">=", date),
@ -32,8 +31,8 @@ class IrSequence(models.Model):
limit=1,
)
if date_range:
date_to = date_range.date_from + relativedelta(days=-1)
date_range = self.env["ir.sequence.date_range"].search(
date_to = fields.Date.subtract(date_range.date_from, days=1)
date_range = sequence_range.search(
[
("sequence_id", "=", self.id),
("date_to", ">=", date_from),
@ -43,16 +42,11 @@ class IrSequence(models.Model):
limit=1,
)
if date_range:
date_from = date_range.date_to + relativedelta(days=1)
seq_date_range = (
self.env["ir.sequence.date_range"]
.sudo()
.create(
{
"date_from": date_from,
"date_to": date_to,
"sequence_id": self.id,
}
)
)
date_to = fields.Date.add(date_range.date_to, days=1)
sequence_range_vals = {
"date_from": date_from,
"date_to": date_to,
"sequence_id": self.id,
}
seq_date_range = sequence_range.sudo().create(sequence_range_vals)
return seq_date_range

View File

@ -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 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.

View File

@ -1,2 +1,3 @@
* Alexis de Lattre <alexis.delattre@akretion.com>
* Moisés López <moylop260@vauxoo.com>
* Francisco Luna <fluna@vauxoo.com>

View File

@ -2,6 +2,8 @@
<!--
Copyright 2021 Akretion France (http://www.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).
-->
<odoo>

View File

@ -10,23 +10,21 @@
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath
<xpath
expr="//div[hasclass('oe_title')]/h1[hasclass('mt0')]"
position="attributes"
>
<attribute
name="attrs"
>{'invisible': [('name', '=', '/')]}</attribute>
</xpath>
<xpath
<attribute name="attrs">{'invisible': [('name', '=', '/')]}</attribute>
</xpath>
<xpath
expr="//div[hasclass('oe_title')]//field[@name='name']"
position="attributes"
>
<attribute name="attrs">{'readonly': 1}</attribute>
</xpath>
<xpath expr="//field[@name='highest_name']/.." position="attributes">
<attribute name="attrs">{'readonly': 1}</attribute>
</xpath>
<xpath expr="//field[@name='highest_name']/.." position="attributes">
<attribute name="attrs">{'invisible': 1}</attribute>
</xpath>
</xpath>
</field>
</record>