From 7ca508bef1db93b1625683bb7846a2de9962408c Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Fri, 25 Dec 2020 17:14:57 +0100 Subject: [PATCH] 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 --- CHANGELOG | 2 ++ purchase.py | 7 ++++++- view/purchase_requisition_line_list.xml | 1 + view/purchase_requisition_line_list_sequence.xml | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a08e3c2d47..31416de7f3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add summary to requisition line + Version 5.8.0 - 2020-11-02 * Bug fixes (see mercurial logs for details) * Remove support for Python 3.5 diff --git a/purchase.py b/purchase.py index af7146b48f..03b836a6b8 100644 --- a/purchase.py +++ b/purchase.py @@ -12,7 +12,7 @@ from trytond.model import Workflow, ModelView, fields, ModelSQL, \ from trytond.model.exceptions import RequiredValidationError, AccessError from trytond.wizard import Wizard from trytond.transaction import Transaction -from trytond.tools import grouped_slice +from trytond.tools import grouped_slice, firstline from trytond.modules.company.model import ( employee_field, set_employee, reset_employee) @@ -460,6 +460,7 @@ class PurchaseRequisitionLine(sequence_ordered(), ModelSQL, ModelView): fields.Many2One('product.uom.category', "Product UOM Category"), 'on_change_with_product_uom_category') description = fields.Text("Description", states=_states, depends=_depends) + summary = fields.Function(fields.Char('Summary'), 'on_change_with_summary') quantity = fields.Float( 'Quantity', digits=(16, Eval('unit_digits', 2)), required=True, states=_states, depends=['unit_digits'] + _depends) @@ -535,6 +536,10 @@ class PurchaseRequisitionLine(sequence_ordered(), ModelSQL, ModelView): self.unit = self.product.purchase_uom self.unit_digits = self.product.purchase_uom.digits + @fields.depends('description') + def on_change_with_summary(self, name=None): + return firstline(self.description or '') + @fields.depends('quantity', 'unit_price', 'unit', 'requisition', '_parent_requisition.currency') def on_change_with_amount(self, name=None): diff --git a/view/purchase_requisition_line_list.xml b/view/purchase_requisition_line_list.xml index ce0f841857..4dc4f6d5f6 100644 --- a/view/purchase_requisition_line_list.xml +++ b/view/purchase_requisition_line_list.xml @@ -4,6 +4,7 @@ this repository contains the full copyright notices and license terms. --> + diff --git a/view/purchase_requisition_line_list_sequence.xml b/view/purchase_requisition_line_list_sequence.xml index 092cc6c055..820f7445a1 100644 --- a/view/purchase_requisition_line_list_sequence.xml +++ b/view/purchase_requisition_line_list_sequence.xml @@ -4,6 +4,7 @@ this repository contains the full copyright notices and license terms. --> +