Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
bd7b1e76 by Cédric Krier at 2022-12-26T22:21:55+01:00
Add invoice party and description to invoice line list
Closes #11904
- - - - -
2 changed files:
- modules/account_invoice/invoice.py
- modules/account_invoice/view/invoice_line_tree.xml
Changes:
=====================================
modules/account_invoice/invoice.py
=====================================
@@ -1926,6 +1926,18 @@
'invisible': Bool(Eval('context', {}).get('standalone')),
'readonly': _states['readonly'] & Bool(Eval('invoice')),
})
+ invoice_party = fields.Function(
+ fields.Many2One(
+ 'party.party', "Party",
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=['company']),
+ 'on_change_with_invoice_party', searcher='search_invoice_party')
+ invoice_description = fields.Function(
+ fields.Char("Invoice Description"),
+ 'on_change_with_invoice_description',
+ searcher='search_invoice_description')
invoice_state = fields.Function(
fields.Selection('get_invoice_states', "Invoice State"),
'on_change_with_invoice_state')
@@ -2180,6 +2192,30 @@
def default_type():
return 'line'
+ @fields.depends('party', 'invoice', '_parent_invoice.party')
+ def on_change_with_invoice_party(self, name=None):
+ if self.invoice and self.invoice.party:
+ return self.invoice.party.id
+ elif self.party:
+ return self.party.id
+
+ @classmethod
+ def search_invoice_party(cls, name, clause):
+ nested = clause[0][len(name) + 1:]
+ return ['OR',
+ ('invoice.party' + nested, *clause[1:]),
+ ('party' + nested, *clause[1:]),
+ ]
+
+ @fields.depends('invoice', '_parent_invoice.description')
+ def on_change_with_invoice_description(self, name=None):
+ if self.invoice:
+ return self.invoice.description
+
+ @classmethod
+ def search_invoice_description(cls, name, clause):
+ return [('invoice.description', *clause[1:])]
+
@classmethod
def default_invoice_state(cls):
return 'draft'
=====================================
modules/account_invoice/view/invoice_line_tree.xml
=====================================
@@ -3,6 +3,7 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="invoice" expand="1"/>
+ <field name="invoice_party" expand="1" optional="0"/>
<field name="type" optional="1"/>
<field name="product" expand="1" optional="0"/>
<field name="summary" expand="1" optional="1"/>
@@ -6,5 +7,5 @@
<field name="type" optional="1"/>
<field name="product" expand="1" optional="0"/>
<field name="summary" expand="1" optional="1"/>
- <field name="account" expand="1" optional="0"/>
+ <field name="account" expand="1" optional="1"/>
<field name="quantity" symbol="unit"/>
@@ -10,4 +11,4 @@
<field name="quantity" symbol="unit"/>
- <field name="unit_price"/>
- <field name="taxes" optional="0"/>
+ <field name="unit_price" optional="1"/>
+ <field name="taxes" optional="1"/>
<field name="amount"/>
@@ -13,2 +14,3 @@
<field name="amount"/>
+ <field name="invoice_description" expand="1" optional="1"/>
</tree>
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/bd7b1e764e0bebbc6cf2ef680a7da3f8cc4fe2c0
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/bd7b1e764e0bebbc6cf2ef680a7da3f8cc4fe2c0
You're receiving this email because of your account on foss.heptapod.net.