Skip to content

Commit

Permalink
Merge d9bd822 into d89b2ab
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Dec 9, 2019
2 parents d89b2ab + d9bd822 commit a22eec3
Show file tree
Hide file tree
Showing 11 changed files with 705 additions and 84 deletions.
2 changes: 1 addition & 1 deletion contract/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright 2016-2018 Tecnativa - Carlos Dauden
# Copyright 2017 Tecnativa - Vicent Cubells
# Copyright 2016-2017 LasLabs Inc.
# Copyright 2018 ACSONE SA/NV
# Copyright 2018-2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
Expand Down
10 changes: 10 additions & 0 deletions contract/migrations/12.0.5.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def migrate(cr, version):
# pre-paid/post-paid becomes significant for monthlylastday too,
# make sure it has the value that was implied for previous versions.
cr.execute(
"""\
UPDATE contract_line
SET recurring_invoicing_type = 'post-paid'
WHERE recurring_rule_type = 'monthlylastday'
"""
)
34 changes: 33 additions & 1 deletion contract/models/abstract_contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,20 @@ class ContractAbstractContractLine(models.AbstractModel):
[('pre-paid', 'Pre-paid'), ('post-paid', 'Post-paid')],
default='pre-paid',
string='Invoicing type',
help="Specify if process date is 'from' or 'to' invoicing date",
help=(
"Specify if the invoice must be generated at the beginning "
"(pre-paid) or end (post-paid) of the period."
),
required=True,
)
recurring_invoicing_offset = fields.Integer(
compute="_compute_recurring_invoicing_offset",
string="Invoicing offset",
help=(
"Number of days to offset the invoice from the period end "
"date (in post-paid mode) or start date (in pre-paid mode)."
)
)
recurring_interval = fields.Integer(
default=1,
string='Invoice Every',
Expand Down Expand Up @@ -115,6 +126,27 @@ class ContractAbstractContractLine(models.AbstractModel):
ondelete='cascade',
)

@api.model
def _get_default_recurring_invoicing_offset(
self, recurring_invoicing_type, recurring_rule_type
):
if (
recurring_invoicing_type == 'pre-paid'
or recurring_rule_type == 'monthlylastday'
):
return 0
else:
return 1

@api.depends('recurring_invoicing_type', 'recurring_rule_type')
def _compute_recurring_invoicing_offset(self):
for rec in self:
rec.recurring_invoicing_offset = (
self._get_default_recurring_invoicing_offset(
rec.recurring_invoicing_type, rec.recurring_rule_type
)
)

@api.depends(
'automatic_price',
'specific_price',
Expand Down

0 comments on commit a22eec3

Please sign in to comment.