changeset 850becf496ad in modules/sale:default details: https://hg.tryton.org/modules/sale?cmd=changeset;node=850becf496ad description: Add summary to line list
A function field summary is added which takes the first line of description field. This is useful to identify line without product (only with description) in the list. issue9695 review292431002 diffstat: CHANGELOG | 1 + sale.py | 7 ++++++- view/sale_line_tree.xml | 1 + view/sale_line_tree_sequence.xml | 1 + 4 files changed, 9 insertions(+), 1 deletions(-) diffs (61 lines): diff -r c406a025d2b5 -r 850becf496ad CHANGELOG --- a/CHANGELOG Wed Dec 23 21:47:15 2020 +0100 +++ b/CHANGELOG Fri Dec 25 17:14:57 2020 +0100 @@ -1,3 +1,4 @@ +* Add summary to sale line list * Add TaxableMixin to sale line Version 5.8.0 - 2020-11-02 diff -r c406a025d2b5 -r 850becf496ad sale.py --- a/sale.py Wed Dec 23 21:47:15 2020 +0100 +++ b/sale.py Fri Dec 25 17:14:57 2020 +0100 @@ -14,7 +14,7 @@ Button from trytond.pyson import If, Eval, Bool, PYSONEncoder from trytond.transaction import Transaction -from trytond.tools import sortable_values +from trytond.tools import sortable_values, firstline from trytond.pool import Pool from trytond.ir.attachment import AttachmentCopyMixin @@ -1119,6 +1119,7 @@ 'readonly': Eval('sale_state') != 'draft', }, depends=['sale_state']) + summary = fields.Function(fields.Char('Summary'), 'on_change_with_summary') note = fields.Text('Note') taxes = fields.Many2Many('sale.line-account.tax', 'line', 'tax', 'Taxes', order=[('tax.sequence', 'ASC'), ('tax.id', 'ASC')], @@ -1334,6 +1335,10 @@ def on_change_taxes(self): self.on_change_quantity() + @fields.depends('description') + def on_change_with_summary(self, name=None): + return firstline(self.description or '') + @fields.depends('type', 'quantity', 'unit_price', 'unit', 'sale', '_parent_sale.currency') def on_change_with_amount(self): diff -r c406a025d2b5 -r 850becf496ad view/sale_line_tree.xml --- a/view/sale_line_tree.xml Wed Dec 23 21:47:15 2020 +0100 +++ b/view/sale_line_tree.xml Fri Dec 25 17:14:57 2020 +0100 @@ -5,6 +5,7 @@ <field name="sale" expand="1"/> <field name="type"/> <field name="product" expand="1"/> + <field name="summary" expand="1"/> <field name="quantity" symbol="unit"/> <field name="unit_price" symbol="currency"/> <field name="taxes"/> diff -r c406a025d2b5 -r 850becf496ad view/sale_line_tree_sequence.xml --- a/view/sale_line_tree_sequence.xml Wed Dec 23 21:47:15 2020 +0100 +++ b/view/sale_line_tree_sequence.xml Fri Dec 25 17:14:57 2020 +0100 @@ -5,6 +5,7 @@ <field name="sale" expand="1"/> <field name="type"/> <field name="product" expand="1"/> + <field name="summary" expand="1"/> <field name="quantity" symbol="unit"/> <field name="unit_price" symbol="currency"/> <field name="taxes"/>