changeset 204a902af354 in modules/production_work_timesheet:default
details: 
https://hg.tryton.org/modules/production_work_timesheet?cmd=changeset;node=204a902af354
description:
        Use equality domain to force work value on timesheet lines

        We add a timesheet_work field to allow to the client to set a value on 
the
        field.

        issue8175
        review255321002
diffstat:

 work.py |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 79d63f77f99d -r 204a902af354 work.py
--- a/work.py   Thu Aug 08 08:29:40 2019 +0200
+++ b/work.py   Mon Oct 14 00:25:02 2019 +0200
@@ -14,6 +14,9 @@
 
     timesheet_works = fields.One2Many(
         'timesheet.work', 'origin', 'Timesheet Works', readonly=True, size=1)
+    timesheet_work = fields.Function(
+        fields.Many2One('timesheet.work', "Timesheet Work"),
+        'get_timesheet_work')
     timesheet_available = fields.Function(
         fields.Boolean('Available on timesheets'),
         'on_change_with_timesheet_available')
@@ -24,11 +27,16 @@
                 },
             domain=[
                 ('company', '=', Eval('company', -1)),
-                ('work', 'in', Eval('timesheet_works', [])),
+                ('work', '=', Eval('timesheet_work', -1)),
                 ],
-            depends=['timesheet_works', 'company']),
+            depends=['timesheet_works', 'timesheet_work', 'company']),
         'get_timesheet_lines', setter='set_timesheet_lines')
 
+    def get_timesheet_work(self, name):
+        if self.timesheet_works:
+            timesheet_work, = self.timesheet_works
+            return timesheet_work.id
+
     @fields.depends('operation')
     def on_change_with_timesheet_available(self, name=None):
         if self.operation:

Reply via email to