-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] Move the constraint on uniqueness for cutoff date at line level…
… + Add the possibility to create several cutoff with the same date Business case can be : - One user (A) creates a cutoff for some account moves. Another user (B) creates other moves, then wants to see those moves in a cutoff. However, B does not want to interfere with the cutoff A already made. B creates a new cutoff with the same date as the one of A, and when he generates lines, only retrieves the one that were not already in the cutoff of A. - One user wants to create several cutoff at the same date, but for different journals/accounts
- Loading branch information
1 parent
efd98e9
commit ed62ead
Showing
8 changed files
with
56 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
import logging | ||
|
||
import odoo | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def migrate(cr, version): | ||
_logger.info("Remove constraint on account cutoff") | ||
odoo.api.Environment(cr, odoo.SUPERUSER_ID, {}) | ||
|
||
cr.execute( | ||
""" | ||
ALTER TABLE account_cutoff | ||
DROP CONSTRAINT IF EXISTS account_cutoff_date_type_company_uniq | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# @author: Alexis de Lattre <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
from odoo import _, fields, models | ||
|
||
|
||
class AccountCutoffLine(models.Model): | ||
|
@@ -12,7 +12,8 @@ class AccountCutoffLine(models.Model): | |
_description = "Account Cut-off Line" | ||
|
||
parent_id = fields.Many2one("account.cutoff", string="Cut-off", ondelete="cascade") | ||
cutoff_type = fields.Selection(related="parent_id.cutoff_type") | ||
cutoff_type = fields.Selection(related="parent_id.cutoff_type", store=True) | ||
cutoff_date = fields.Date(related="parent_id.cutoff_date", store=True) | ||
company_id = fields.Many2one( | ||
"res.company", related="parent_id.company_id", store=True | ||
) | ||
|
@@ -83,3 +84,11 @@ class AccountCutoffLine(models.Model): | |
readonly=True, | ||
) | ||
notes = fields.Text() | ||
|
||
_sql_constraints = [ | ||
( | ||
"line_date_type_company_uniq", | ||
"unique(cutoff_date, company_id, cutoff_type, origin_move_line_id)", | ||
_("A cutoff line of the same type already exists with this cut-off date !"), | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import account_cutoff | ||
from . import account_cutoff_line | ||
from . import account_move_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
account_cutoff_start_end_dates/models/account_move_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AccountMoveLine(models.Model): | ||
|
||
_inherit = "account.move.line" | ||
cutoff_line_ids = fields.One2many( | ||
"account.cutoff.line", | ||
inverse_name="origin_move_line_id", | ||
string="Related cutoff line", | ||
readonly=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters