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 3 times, most recently 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 thread contract_invoice_suspended/README.rst Outdated
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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

is it okay like this ?

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.

Not quite, please see the documentation: https://www.odoo-community.org/readme-structure

There are dedicated fragments for "Usage" and "Configure", they should not be sub-section of the "Description" fragment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored this , is this okay now ?

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

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])]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored

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
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes , refactored

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 was a genuine question. Are you 100% sure this is correct and efficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i tested it works fine also if i understood well the functionality also this test is paasing fine ,test_compute_suspended_reason_category_id

@bjouini-acsone
bjouini-acsone force-pushed the 18.0-add-contract_invoice_suspended branch 4 times, most recently from 704d3d9 to 990f45d Compare August 17, 2026 13:16
@bjouini-acsone
bjouini-acsone force-pushed the 18.0-add-contract_invoice_suspended branch from 990f45d to d7170cf Compare August 26, 2026 10:35
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