changeset 5de53725b2d0 in modules/stock_supply_day:default
details: 
https://hg.tryton.org/modules/stock_supply_day?cmd=changeset;node=5de53725b2d0
description:
        Use multiselection for days

        issue8894
        review264881004
diffstat:

 CHANGELOG                                       |   2 ++
 purchase.py                                     |  25 ++++++++++---------------
 purchase.xml                                    |  22 ----------------------
 view/product_supplier_form.xml                  |   4 ++--
 view/product_supplier_weekday_form.xml          |  10 ----------
 view/product_supplier_weekday_tree.xml          |   7 -------
 view/product_supplier_weekday_tree_editable.xml |   7 -------
 7 files changed, 14 insertions(+), 63 deletions(-)

diffs (157 lines):

diff -r 7737feb40c40 -r 5de53725b2d0 CHANGELOG
--- a/CHANGELOG Wed Dec 04 11:09:37 2019 +0100
+++ b/CHANGELOG Wed Dec 18 21:41:21 2019 +0100
@@ -1,3 +1,5 @@
+* Use multiselection for days
+
 Version 5.4.0 - 2019-11-04
 * Bug fixes (see mercurial logs for details)
 
diff -r 7737feb40c40 -r 5de53725b2d0 purchase.py
--- a/purchase.py       Wed Dec 04 11:09:37 2019 +0100
+++ b/purchase.py       Wed Dec 18 21:41:21 2019 +0100
@@ -1,7 +1,7 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 import datetime
-from trytond.model import ModelView, ModelSQL, fields
+from trytond.model import ModelSQL, fields
 from trytond.pool import PoolMeta, Pool
 from trytond.transaction import Transaction
 
@@ -10,16 +10,16 @@
 
 class ProductSupplier(metaclass=PoolMeta):
     __name__ = 'purchase.product_supplier'
-    weekdays = fields.One2Many('purchase.product_supplier.day',
-        'product_supplier', 'Week Days')
+    weekdays = fields.Many2Many(
+        'purchase.product_supplier.day', 'product_supplier', 'day',
+        "Week Days")
 
     def compute_supply_date(self, date=None):
         date = super(ProductSupplier, self).compute_supply_date(date=date)
         earlier_date = None
         if date != datetime.date.max:
             for weekday in self.weekdays:
-                weekday = weekday.day.index
-                diff = weekday - date.weekday()
+                diff = weekday.index - date.weekday()
                 if diff < 0:
                     diff += 7
                 new_date = date + datetime.timedelta(diff)
@@ -32,8 +32,7 @@
     def compute_purchase_date(self, date):
         later_date = None
         for weekday in self.weekdays:
-            weekday = weekday.day.index
-            diff = (date.weekday() - weekday) % 7
+            diff = (date.weekday() - weekday.index) % 7
             new_date = date - datetime.timedelta(diff)
             if later_date and later_date >= new_date:
                 continue
@@ -43,11 +42,12 @@
         return super(ProductSupplier, self).compute_purchase_date(date)
 
 
-class ProductSupplierDay(ModelSQL, ModelView):
+class ProductSupplierDay(ModelSQL):
     'Product Supplier Day'
     __name__ = 'purchase.product_supplier.day'
-    product_supplier = fields.Many2One('purchase.product_supplier', 'Supplier',
-            required=True, ondelete='CASCADE')
+    product_supplier = fields.Many2One(
+        'purchase.product_supplier', 'Supplier',
+        required=True, ondelete='CASCADE', select=True)
     day = fields.Many2One('ir.calendar.day', "Day", required=True)
 
     @classmethod
@@ -71,8 +71,3 @@
                         [table.day], [day_id],
                         where=table.weekday == str(index)))
             table_h.drop_column('weekday')
-
-    @classmethod
-    def __setup__(cls):
-        super(ProductSupplierDay, cls).__setup__()
-        cls._order.insert(0, ('day', 'ASC'))
diff -r 7737feb40c40 -r 5de53725b2d0 purchase.xml
--- a/purchase.xml      Wed Dec 04 11:09:37 2019 +0100
+++ b/purchase.xml      Wed Dec 18 21:41:21 2019 +0100
@@ -8,27 +8,5 @@
             <field name="inherit" ref="purchase.product_supplier_view_form"/>
             <field name="name">product_supplier_form</field>
         </record>
-
-        <record model="ir.ui.view" id="product_supplier_weekdayview_form">
-            <field name="model">purchase.product_supplier.day</field>
-            <field name="type">form</field>
-            <field name="name">product_supplier_weekday_form</field>
-        </record>
-
-        <record model="ir.ui.view" id="product_supplier_weekdayview_tree">
-            <field name="model">purchase.product_supplier.day</field>
-            <field name="type">tree</field>
-            <field name="priority" eval="10"/>
-            <field name="name">product_supplier_weekday_tree</field>
-        </record>
-
-        <record model="ir.ui.view"
-            id="product_supplier_weekdayview_tree_editable">
-            <field name="model">purchase.product_supplier.day</field>
-            <field name="type">tree</field>
-            <field name="priority" eval="20"/>
-            <field name="name">product_supplier_weekday_tree_editable</field>
-        </record>
-
     </data>
 </tryton>
diff -r 7737feb40c40 -r 5de53725b2d0 view/product_supplier_form.xml
--- a/view/product_supplier_form.xml    Wed Dec 04 11:09:37 2019 +0100
+++ b/view/product_supplier_form.xml    Wed Dec 18 21:41:21 2019 +0100
@@ -3,7 +3,7 @@
 this repository contains the full copyright notices and license terms. -->
 <data>
     <xpath expr="/form/field[@name='lead_time']" position="after">
-        <field name="weekdays" colspan="4"
-            
view_ids="stock_supply_day.product_supplier_weekdayview_tree_editable"/>
+        <label name="weekdays"/>
+        <field name="weekdays" widget="multiselection" yexpand="0"/>
     </xpath>
 </data>
diff -r 7737feb40c40 -r 5de53725b2d0 view/product_supplier_weekday_form.xml
--- a/view/product_supplier_weekday_form.xml    Wed Dec 04 11:09:37 2019 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
-this repository contains the full copyright notices and license terms. -->
-<form>
-    <label name="product_supplier"/>
-    <field name="product_supplier"/>
-    <newline/>
-    <label name="day"/>
-    <field name="day" widget="selection"/>
-</form>
diff -r 7737feb40c40 -r 5de53725b2d0 view/product_supplier_weekday_tree.xml
--- a/view/product_supplier_weekday_tree.xml    Wed Dec 04 11:09:37 2019 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-<?xml version="1.0"?>
-<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
-this repository contains the full copyright notices and license terms. -->
-<tree>
-    <field name="product_supplier"/>
-    <field name="day" widget="selection"/>
-</tree>
diff -r 7737feb40c40 -r 5de53725b2d0 
view/product_supplier_weekday_tree_editable.xml
--- a/view/product_supplier_weekday_tree_editable.xml   Wed Dec 04 11:09:37 
2019 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-<?xml version="1.0"?>
-<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
-this repository contains the full copyright notices and license terms. -->
-<tree editable="bottom">
-    <field name="product_supplier"/>
-    <field name="day" expand="1" widget="selection"/>
-</tree>

Reply via email to