Merge lp:~unifield-team/unifield-wm/uf-2511 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2297
Proposed branch: lp:~unifield-team/unifield-wm/uf-2511
Merge into: lp:unifield-wm
Diff against target: 90 lines (+34/-4)
2 files modified
threshold_value/threshold_value.py (+31/-1)
threshold_value/threshold_value_view.xml (+3/-3)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/uf-2511
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+237965@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'threshold_value/threshold_value.py'
2--- threshold_value/threshold_value.py 2014-01-15 09:14:35 +0000
3+++ threshold_value/threshold_value.py 2014-10-10 12:33:23 +0000
4@@ -22,10 +22,11 @@
5
6 from osv import osv
7 from osv import fields
8+from tools.translate import _
9
10 from mx.DateTime import DateFrom
11 from mx.DateTime import now
12-from mx.DateTime import RelativeDate
13+from mx.DateTime import RelativeDate
14
15 class threshold_value(osv.osv):
16 _name = 'threshold.value'
17@@ -260,6 +261,23 @@
18 ret = super(threshold_value, self).write(cr, uid, ids, vals, context=context)
19 return ret
20
21+ def on_change_compute_method(self, cr, uid, ids, compute_method,
22+ context=None):
23+ res = {}
24+ if compute_method and compute_method == 'computed':
25+ # UF-2511: switch from 'fixed' to 'compute' compute method
26+ # warn user to refresh values
27+ # (are not any more computed in 'fixed' mode)
28+ msg = "You switch from 'fixed values' to 'computed values'. " \
29+ "Please click on 'Refresh values' button to compute values."
30+ res = {
31+ 'warning': {
32+ 'title': _('Warning'),
33+ 'message': _(msg),
34+ },
35+ }
36+ return res
37+
38 threshold_value()
39
40 class threshold_value_line(osv.osv):
41@@ -349,6 +367,18 @@
42 res = {}
43
44 for line in self.browse(cr, uid, ids, context=context):
45+ if context and context.get('compute_method', False) == 'fixed':
46+ # UF-2511: do not compute in 'fixed' compute method mode
47+ res[line.id] = {
48+ 'consumption': 0.,
49+ 'real_stock': 0.,
50+ 'available_stock': 0.,
51+ 'expiry_before': False,
52+ 'supplier_id': False,
53+ 'required_date': False,
54+ }
55+ continue
56+
57 # Stock values
58 location_id = line.threshold_value_id.location_id.id
59 stock_product = product_obj.browse(cr, uid, line.product_id.id, context=dict(context, location=location_id))
60
61=== modified file 'threshold_value/threshold_value_view.xml'
62--- threshold_value/threshold_value_view.xml 2014-03-14 09:48:25 +0000
63+++ threshold_value/threshold_value_view.xml 2014-10-10 12:33:23 +0000
64@@ -12,7 +12,7 @@
65 <separator colspan="4" string="General Information" />
66 <field name="name" />
67 <field name="warehouse_id" widget="selection" on_change="onchange_warehouse_id(warehouse_id)" />
68- <field name="compute_method" />
69+ <field name="compute_method" on_change="on_change_compute_method(compute_method)"/>
70 <field name="location_id" />
71 <field name="active" attrs="{'invisible': [('compute_method', '=', False)]}" />
72 <newline />
73@@ -49,7 +49,7 @@
74
75 <group colspan="4" col="4" attrs="{'invisible': [('compute_method', '=', False)]}">
76 <button colspan="4" icon="gtk-execute" string="Refresh values" type="object" name="dummy" />
77- <field name="line_ids" nolabel="1" colspan="4" attrs="{'invisible': [('compute_method', '!=', 'computed')]}" context="{'rule_id': active_id}">
78+ <field name="line_ids" nolabel="1" colspan="4" attrs="{'invisible': [('compute_method', '!=', 'computed')]}" context="{'rule_id': active_id, 'compute_method': compute_method}">
79 <tree string="Products" editable="top">
80 <field name="product_id" domain="[('list_ids', '=', parent.sublist_id), ('type', 'not in', ['service', 'service_recep', 'consu'])]"
81 on_change="onchange_product_id(product_id, parent.compute_method, parent.consumption_method, parent.consumption_period_from, parent.consumption_period_to, parent.frequency, parent.safety_month, parent.lead_time,parent.supplier_lt, fixed_threshold_value, fixed_product_qty, False, 'product_id', context)"/>
82@@ -66,7 +66,7 @@
83 </tree>
84 </field>
85
86- <field name="fixed_line_ids" nolabel="1" colspan="4" attrs="{'invisible': [('compute_method', '!=', 'fixed')]}">
87+ <field name="fixed_line_ids" nolabel="1" colspan="4" attrs="{'invisible': [('compute_method', '!=', 'fixed')]}" context="{'compute_method': compute_method}">
88 <tree string="Products" editable="top">
89 <field name="product_id" domain="[('list_ids', '=', parent.sublist_id), ('type', 'not in', ['service', 'service_recep', 'consu'])]"
90 on_change="onchange_product_id(product_id, parent.compute_method, parent.consumption_method, parent.consumption_period_from, parent.consumption_period_to, parent.frequency, parent.safety_month, parent.lead_time,parent.supplier_lt, fixed_threshold_value, fixed_product_qty, context)"/>

Subscribers

People subscribed via source and target branches