Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contract_invoice_manually/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Tobias Zehntner <tobias.zehntner@acsone.eu> (https://www.acsone.eu)
- Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Copyright 2026 ACSONE SA/NV
# Copyright 2026 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import api, fields, models
from odoo.osv import expression
from odoo.tools.safe_eval import safe_eval


class ContractManuallyCreateInvoice(models.TransientModel):
_inherit = "contract.manually.create.invoice"

manually_invoiced = fields.Boolean(
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.

Suggested change
manually_invoiced = fields.Boolean(
is_manually_invoiced = fields.Boolean(
"Only Manually Invoiced Contracts

Yes that could add some flexibility (even though it's already there via the filter for the technically versed users)

default=lambda self: self.env.company.enable_contract_invoice_manually
)

filter_domain = fields.Char(
string="Domain",
compute="_compute_filter_domain",
Expand All @@ -18,7 +22,7 @@ class ContractManuallyCreateInvoice(models.TransientModel):
help="Filter/Domain to apply on contracts to invoice",
)

@api.depends("invoice_date", "contract_type")
@api.depends("invoice_date", "contract_type", "manually_invoiced")
def _compute_filter_domain(self):
for wizard in self:
domain = [
Expand All @@ -28,9 +32,8 @@ def _compute_filter_domain(self):
fields.Datetime.to_string(wizard.invoice_date),
),
("contract_type", "=", wizard.contract_type),
("is_manually_invoiced", "=", wizard.manually_invoiced),
]
if self.env.company.enable_contract_invoice_manually:
domain = expression.AND([domain, [("is_manually_invoiced", "=", True)]])
Comment on lines +35 to -33
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.

I don't know what your use case is, but I think it's not clear from the boolean in the view that unticking it would exclude the manually invoiced contracts. Maybe only add the domain if it's ticked, and otherwise include both types of contracts?

wizard.filter_domain = str(domain)

@api.depends("invoice_date", "filter_domain")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@
ref="contract.contract_manually_create_invoice_form_view"
/>
<field name="arch" type="xml">
<xpath expr="//form/group[last()]" position="after">
<notebook invisible="not invoice_date">
<page name="contracts" string="Contracts">
<button
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 button is fixed here: #1391

name="action_show_contract_to_invoice"
position="move"
/>
</page>
<page name="domain" string="Contract Filter">
<field
name="filter_domain"
widget="domain"
options="{'model': 'contract.contract'}"
/>
</page>
</notebook>
<field name="invoice_date" position="after">
<field name="manually_invoiced" />
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 should only show when the config setting is active

</field>
<xpath expr="//form/group" position="after">
<group
string="Contract Filter"
invisible="not invoice_date"
groups="base.group_no_one"
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.

I find it's too limiting to put the filter only for debug-mode. Our clients use filtering regularly but aren't necessarily familiar with debug mode. However, I agree it's a bit of an extra technical thing, hence my reasoning to put it away in a second tab: accessible but not confusing.

>
<field
name="filter_domain"
widget="domain"
options="{'model': 'contract.contract'}"
/>
</group>
</xpath>
</field>
</record>
Expand Down
Loading