details: https://code.tryton.org/tryton/commit/74e03666d782
branch: default
user: Cédric Krier <[email protected]>
date: Mon Feb 16 19:19:01 2026 +0100
description:
Enforce invoice type for origin of invoice line
Closes #14611
diffstat:
modules/purchase/invoice.py | 9 ++++++++-
modules/purchase/invoice.xml | 2 +-
modules/sale/invoice.py | 9 ++++++++-
modules/sale/invoice.xml | 2 +-
modules/sale_rental/account.py | 16 ++++++++++++++++
modules/sale_rental/account.xml | 2 +-
modules/sale_subscription/invoice.py | 16 ++++++++++++++++
modules/sale_subscription/subscription.xml | 2 +-
8 files changed, 52 insertions(+), 6 deletions(-)
diffs (164 lines):
diff -r 88b10fd239f3 -r 74e03666d782 modules/purchase/invoice.py
--- a/modules/purchase/invoice.py Mon Feb 16 17:22:16 2026 +0100
+++ b/modules/purchase/invoice.py Mon Feb 16 19:19:01 2026 +0100
@@ -6,7 +6,7 @@
from trytond.model import ModelView, Workflow, fields
from trytond.model.exceptions import AccessError
from trytond.pool import Pool, PoolMeta
-from trytond.pyson import Eval
+from trytond.pyson import Bool, Eval, If
from trytond.tools import cached_property
from trytond.transaction import Transaction, without_check_access
@@ -110,6 +110,13 @@
cls.origin.domain = {}
cls.origin.domain['purchase.line'] = [
('type', '=', Eval('type')),
+ If(Bool(Eval('_parent_invoice')),
+ If(Eval('_parent_invoice', {}).get('type') != 'in',
+ ('id', '=', -1),
+ ()),
+ If(Eval('invoice_type') != 'in',
+ ('id', '=', -1),
+ ())),
]
@cached_property
diff -r 88b10fd239f3 -r 74e03666d782 modules/purchase/invoice.xml
--- a/modules/purchase/invoice.xml Mon Feb 16 17:22:16 2026 +0100
+++ b/modules/purchase/invoice.xml Mon Feb 16 19:19:01 2026 +0100
@@ -9,7 +9,7 @@
<field name="context"></field>
<field
name="domain"
- eval="[('purchases.id', 'in', Eval('active_ids', []))]"
+ eval="[('purchases.id', 'in', Eval('active_ids', [])),
('type', '=', 'in')]"
pyson="1"/>
</record>
<record model="ir.action.keyword"
diff -r 88b10fd239f3 -r 74e03666d782 modules/sale/invoice.py
--- a/modules/sale/invoice.py Mon Feb 16 17:22:16 2026 +0100
+++ b/modules/sale/invoice.py Mon Feb 16 19:19:01 2026 +0100
@@ -6,7 +6,7 @@
from trytond.model import Workflow, fields
from trytond.model.exceptions import AccessError
from trytond.pool import Pool, PoolMeta
-from trytond.pyson import Eval
+from trytond.pyson import Bool, Eval, If
from trytond.transaction import Transaction, without_check_access
@@ -118,6 +118,13 @@
cls.origin.domain = {}
cls.origin.domain['sale.line'] = [
('type', '=', Eval('type')),
+ If(Bool(Eval('_parent_invoice')),
+ If(Eval('_parent_invoice', {}).get('type') != 'out',
+ ('id', '=', -1),
+ ()),
+ If(Eval('invoice_type') != 'out',
+ ('id', '=', -1),
+ ())),
]
@fields.depends('origin')
diff -r 88b10fd239f3 -r 74e03666d782 modules/sale/invoice.xml
--- a/modules/sale/invoice.xml Mon Feb 16 17:22:16 2026 +0100
+++ b/modules/sale/invoice.xml Mon Feb 16 19:19:01 2026 +0100
@@ -8,7 +8,7 @@
<field name="res_model">account.invoice</field>
<field
name="domain"
- eval="[('sales.id', 'in', Eval('active_ids', []))]"
+ eval="[('sales.id', 'in', Eval('active_ids', [])), ('type',
'=', 'out')]"
pyson="1"/>
</record>
<record model="ir.action.keyword"
diff -r 88b10fd239f3 -r 74e03666d782 modules/sale_rental/account.py
--- a/modules/sale_rental/account.py Mon Feb 16 17:22:16 2026 +0100
+++ b/modules/sale_rental/account.py Mon Feb 16 19:19:01 2026 +0100
@@ -3,6 +3,7 @@
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
+from trytond.pyson import Bool, Eval, If
from trytond.report import Report
from trytond.tools import cached_property
@@ -34,6 +35,21 @@
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
+ @classmethod
+ def __setup__(cls):
+ super().__setup__()
+ if not cls.origin.domain:
+ cls.origin.domain = {}
+ cls.origin.domain['sale.rental.line'] = [
+ If(Bool(Eval('_parent_invoice')),
+ If(Eval('_parent_invoice', {}).get('type') != 'out',
+ ('id', '=', -1),
+ ()),
+ If(Eval('invoice_type') != 'out',
+ ('id', '=', -1),
+ ())),
+ ]
+
@fields.depends('product', 'origin')
def on_change_product(self):
pool = Pool()
diff -r 88b10fd239f3 -r 74e03666d782 modules/sale_rental/account.xml
--- a/modules/sale_rental/account.xml Mon Feb 16 17:22:16 2026 +0100
+++ b/modules/sale_rental/account.xml Mon Feb 16 19:19:01 2026 +0100
@@ -8,7 +8,7 @@
<field name="res_model">account.invoice</field>
<field
name="domain"
- eval="[('sale_rentals.id', 'in', Eval('active_ids', []))]"
+ eval="[('sale_rentals.id', 'in', Eval('active_ids', [])),
('type', '=', 'out')]"
pyson="1"/>
</record>
<record model="ir.action.keyword"
id="act_account_invoice_form_keyword1">
diff -r 88b10fd239f3 -r 74e03666d782 modules/sale_subscription/invoice.py
--- a/modules/sale_subscription/invoice.py Mon Feb 16 17:22:16 2026 +0100
+++ b/modules/sale_subscription/invoice.py Mon Feb 16 19:19:01 2026 +0100
@@ -1,11 +1,27 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool, PoolMeta
+from trytond.pyson import Bool, Eval, If
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
+ @classmethod
+ def __setup__(cls):
+ super().__setup__()
+ if not cls.origin.domain:
+ cls.origin.domain = {}
+ cls.origin.domain['sale.subscription.line'] = [
+ If(Bool(Eval('_parent_invoice')),
+ If(Eval('_parent_invoice', {}).get('type') != 'out',
+ ('id', '=', -1),
+ ()),
+ If(Eval('invoice_type') != 'out',
+ ('id', '=', -1),
+ ())),
+ ]
+
@property
def origin_name(self):
pool = Pool()
diff -r 88b10fd239f3 -r 74e03666d782 modules/sale_subscription/subscription.xml
--- a/modules/sale_subscription/subscription.xml Mon Feb 16 17:22:16
2026 +0100
+++ b/modules/sale_subscription/subscription.xml Mon Feb 16 19:19:01
2026 +0100
@@ -218,7 +218,7 @@
<field name="res_model">account.invoice</field>
<field
name="domain"
- eval="[('lines.origin.subscription.id', 'in',
Eval('active_ids'), 'sale.subscription.line')]"
+ eval="[('lines.origin.subscription.id', 'in',
Eval('active_ids'), 'sale.subscription.line'), ('type', '=', 'out')]"
pyson="1"/>
</record>
<record model="ir.action.keyword"
id="act_subscription_invoice_relate_keyword1">