Skip to content

[18.0][ADD]contract_invoice_suspended - #1494

Open
bjouini-acsone wants to merge 1 commit into
OCA:18.0from
acsone:18.0-add-contract_invoice_suspended
Open

[18.0][ADD]contract_invoice_suspended#1494
bjouini-acsone wants to merge 1 commit into
OCA:18.0from
acsone:18.0-add-contract_invoice_suspended

Conversation

@bjouini-acsone

Copy link
Copy Markdown
Contributor

No description provided.

@OCA-git-bot OCA-git-bot added series:18.0 mod:contract_invoice_suspended Module contract_invoice_suspended labels Aug 4, 2026
@bjouini-acsone
bjouini-acsone force-pushed the 18.0-add-contract_invoice_suspended branch 2 times, most recently from 19fdfd7 to a383014 Compare August 4, 2026 10:32
@bjouini-acsone
bjouini-acsone force-pushed the 18.0-add-contract_invoice_suspended branch from a383014 to 36ac1ab Compare August 4, 2026 10:42
@bjouini-acsone bjouini-acsone changed the title [ADD]contract_invoice_suspended [18.0][ADD]contract_invoice_suspended Aug 4, 2026

@qgroulard qgroulard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for this contribution !

It would be nice to provide a bit more context 🙂

Comment on lines +1 to +6
==========================
Contract Invoice Suspended
==========================

This module provides functionality to suspend automatic invoicing for
contracts with configurable reasons and tracking.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow oca guidelines: https://www.odoo-community.org/readme-structure

Could you please also elaborate? What's the point of this module? How to configure it? etc.
Try to think of this module as if it was completely unknown to you, what would you like to know about it?

Comment on lines +14 to +17
# OCA
"contract_line_successor",
# OCA/contract
"contract_sale",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these two separated?

Comment on lines +43 to +46
<field
name="domain_force"
>['|', ('company_id','=',False), ('company_id','parent_of',company_ids)]</field>
</record>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new convention for multi-company rule is:

        [('company_id', 'in', company_ids + [False])]

Comment on lines +47 to +83
@api.depends("parent_id.suspended_reason_category_id")
def _compute_suspended_reason_category_id(self):
self.env.cr.execute(
"""
WITH RECURSIVE trid(id, parent_id,
suspended_reason_category_id, final) AS (
SELECT
id, parent_id, id,
(parent_id IS NULL) as final
FROM contract_automatic_invoice_suspension_reason
WHERE id = ANY(%s)
UNION
SELECT
trid.id, ctr.parent_id, ctr.id,
(ctr.parent_id IS NULL) as final
FROM contract_automatic_invoice_suspension_reason ctr
JOIN trid ON (trid.parent_id = ctr.id)
WHERE NOT trid.final
)
SELECT trid.id, trid.suspended_reason_category_id
FROM trid
WHERE final AND id = ANY(%s);
""",
[self.ids, self.ids],
)

d = dict(self.env.cr.fetchall())
for suspension_reason in self:
fetched = d.get(suspension_reason.id)
if fetched is not None:
suspension_reason.suspended_reason_category_id = fetched
elif not suspension_reason.parent_id:
suspension_reason.suspended_reason_category_id = suspension_reason
else:
suspension_reason.suspended_reason_category_id = (
suspension_reason.parent_id.suspended_reason_category_id
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks super complicated to me.
Why can't we do something like:

Suggested change
@api.depends("parent_id.suspended_reason_category_id")
def _compute_suspended_reason_category_id(self):
self.env.cr.execute(
"""
WITH RECURSIVE trid(id, parent_id,
suspended_reason_category_id, final) AS (
SELECT
id, parent_id, id,
(parent_id IS NULL) as final
FROM contract_automatic_invoice_suspension_reason
WHERE id = ANY(%s)
UNION
SELECT
trid.id, ctr.parent_id, ctr.id,
(ctr.parent_id IS NULL) as final
FROM contract_automatic_invoice_suspension_reason ctr
JOIN trid ON (trid.parent_id = ctr.id)
WHERE NOT trid.final
)
SELECT trid.id, trid.suspended_reason_category_id
FROM trid
WHERE final AND id = ANY(%s);
""",
[self.ids, self.ids],
)
d = dict(self.env.cr.fetchall())
for suspension_reason in self:
fetched = d.get(suspension_reason.id)
if fetched is not None:
suspension_reason.suspended_reason_category_id = fetched
elif not suspension_reason.parent_id:
suspension_reason.suspended_reason_category_id = suspension_reason
else:
suspension_reason.suspended_reason_category_id = (
suspension_reason.parent_id.suspended_reason_category_id
)
@api.depends("parent_id.suspended_reason_category_id")
def _compute_suspended_reason_category_id(self):
for suspension_reason in self:
suspension_reason.suspended_reason_category_id = (
suspension_reason.parent_id.suspended_reason_category_id
or suspension_reason
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:contract_invoice_suspended Module contract_invoice_suspended series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants