Merge lp:~julie-w/unifield-server/US-3610 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4561
Proposed branch: lp:~julie-w/unifield-server/US-3610
Merge into: lp:unifield-server
Diff against target: 163 lines (+62/-15)
4 files modified
bin/addons/msf_instance/account.py (+35/-13)
bin/addons/msf_profile/i18n/fr_MF.po (+10/-0)
bin/addons/vertical_integration/vertical_integration_wizard.xml (+7/-2)
bin/addons/vertical_integration/wizard/wizard_hq_report_ocg.py (+10/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-3610
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+332471@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 'bin/addons/msf_instance/account.py'
2--- bin/addons/msf_instance/account.py 2016-09-09 13:19:09 +0000
3+++ bin/addons/msf_instance/account.py 2017-10-19 09:52:15 +0000
4@@ -26,7 +26,7 @@
5 _name = 'account.period'
6 _inherit = 'account.period'
7
8- def _get_child_mission_closed(self, cr, uid, ids, name, args, context=None):
9+ def _get_child_state(self, cr, uid, ids, name, args, context=None):
10 """
11 Fake method / always returns False
12 """
13@@ -39,12 +39,14 @@
14 res[id] = False
15 return res
16
17- def _search_child_mission_closed(self, cr, uid, obj, name, args, context=None):
18- '''
19- Returns a domain corresponding to mission-closed periods for the selected fiscal year
20- - if in HQ: the periods must be "mission-closed" in the selected coordo (the status in HQ doesn't matter)
21- - else: the periods must be "mission-closed" in the current instance
22- '''
23+ def _search_child_states(self, cr, uid, obj, name, args, period_states=None, context=None):
24+ """
25+ Returns a domain corresponding to periods having specific states for the selected fiscal year.
26+ The period states:
27+ - correspond to: the tuple of period_states given in parameter, or mission-closed by default
28+ - if in HQ: are those from the selected coordo
29+ - else: are those from the current instance
30+ """
31 res = []
32 period_ids = []
33 user_obj = self.pool.get('res.users')
34@@ -56,12 +58,14 @@
35 if args[0][1] != '=':
36 msg = _("Operator %s not supported") % (args[0][1], )
37 raise osv.except_osv(_('Error'), msg)
38- if args[0][0] != 'child_mission_closed' or not args[0][2]:
39+ if not args[0][2]:
40 return res
41 # if no fiscal year selected: don't display any periods
42 fy = args[0][2][1]
43 if not fy:
44 return [('id', 'in', [])]
45+ if not period_states:
46+ period_states = ('mission-closed',)
47 # if the current instance is an HQ
48 instance_id = user_obj.browse(cr, uid, uid, context=context).company_id.instance_id
49 if instance_id and instance_id.level == 'section':
50@@ -69,30 +73,48 @@
51 prop_inst = args[0][2][0]
52 if not prop_inst:
53 return [('id', 'in', [])]
54- # else get the mission-closed periods
55+ # else get the periods having the required state(s)
56 sql_get_periods = """
57 SELECT ps.period_id
58 FROM account_period_state ps
59 INNER JOIN account_period p
60 ON ps.period_id = p.id
61- WHERE ps.state = 'mission-closed'
62+ WHERE ps.state in %s
63 AND ps.instance_id = %s
64 AND p.fiscalyear_id = %s;"""
65- cr.execute(sql_get_periods, (prop_inst, fy))
66+ cr.execute(sql_get_periods, (period_states, prop_inst, fy))
67 for line in cr.fetchall():
68 period_ids.append(line[0])
69 res.append(('id', 'in', period_ids))
70 else:
71 # if not in HQ
72- res.extend([('state', '=', 'mission-closed'), ('fiscalyear_id', '=', fy)])
73+ res.extend([('state', 'in', period_states), ('fiscalyear_id', '=', fy)])
74 return res
75
76+ def _search_child_mission_closed(self, cr, uid, obj, name, args, context=None):
77+ """
78+ Returns a domain with mission-closed periods for the selected FY & coordo (or for the current inst. if not in HQ)
79+ """
80+ return self._search_child_states(cr, uid, obj, name, args, context=context)
81+
82+ def _search_child_mission_hq_closed(self, cr, uid, obj, name, args, context=None):
83+ """
84+ Returns a domain with mission-closed or HQ-closed periods for the selected FY & coordo (or for the current inst. if not in HQ)
85+ """
86+ states = ('mission-closed', 'done',)
87+ return self._search_child_states(cr, uid, obj, name, args, period_states=states, context=context)
88+
89 _columns = {
90- 'child_mission_closed': fields.function(_get_child_mission_closed, method=True, store=False,
91+ 'child_mission_closed': fields.function(_get_child_state, method=True, store=False,
92 string='Child Mission Closed',
93 help='In HQ, check the periods being mission-closed in the selected coordo',
94 type='boolean',
95 fnct_search=_search_child_mission_closed),
96+ 'child_mission_hq_closed': fields.function(_get_child_state, method=True, store=False,
97+ string='Child Mission or HQ Closed',
98+ help='In HQ, checks the periods being mission or HQ-closed in the selected coordo',
99+ type='boolean',
100+ fnct_search=_search_child_mission_hq_closed),
101 }
102
103 def action_set_state(self, cr, uid, ids, context=None):
104
105=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
106--- bin/addons/msf_profile/i18n/fr_MF.po 2017-10-09 16:01:14 +0000
107+++ bin/addons/msf_profile/i18n/fr_MF.po 2017-10-19 09:52:15 +0000
108@@ -99629,3 +99629,13 @@
109 #, python-format
110 msgid "You can't delete this FX rate as the period \"%s\" isn't in Draft state."
111 msgstr "Vous ne pouvez pas supprimer ce taux de change car la période \"%s\" n'est pas en statut Brouillon."
112+
113+#. module: msf_instance
114+#: field:account.period,child_mission_hq_closed:0
115+msgid "Child Mission or HQ Closed"
116+msgstr "Fermé en mission ou en HQ dans l'instance enfant"
117+
118+#. module: msf_instance
119+#: help:account.period,child_mission_hq_closed:0
120+msgid "In HQ, checks the periods being mission or HQ-closed in the selected coordo"
121+msgstr "En HQ, vérifie les périodes fermées en mission ou en HQ dans la coordo sélectionnée"
122
123=== modified file 'bin/addons/vertical_integration/vertical_integration_wizard.xml'
124--- bin/addons/vertical_integration/vertical_integration_wizard.xml 2016-11-16 14:12:40 +0000
125+++ bin/addons/vertical_integration/vertical_integration_wizard.xml 2017-10-19 09:52:15 +0000
126@@ -10,9 +10,14 @@
127 <field name="type">form</field>
128 <field name="arch" type="xml">
129 <form string="Export to HQ system">
130- <field name="instance_id" domain="['&amp;', ('level', '=', 'coordo'), ('instance_to_display_ids','=',True)]"/>
131+ <field name="instance_id"
132+ domain="['&amp;', ('level', '=', 'coordo'), ('instance_to_display_ids', '=', True)]"
133+ on_change="onchange_instance_id()"/>
134 <field name="fiscalyear_id"/>
135- <field name="period_id" domain="[('fiscalyear_id', '=', fiscalyear_id), ('state', '&lt;&gt;', 'created'), ('number', '&lt;', 16)]"/>
136+ <field name="period_id" domain="[('fiscalyear_id', '=', fiscalyear_id),
137+ ('state', '&lt;&gt;', 'created'),
138+ ('number', '&lt;', 16),
139+ ('child_mission_hq_closed', '=', [instance_id, fiscalyear_id])]"/>
140 <newline/>
141 <button icon="terp-camera_test" string="Export" name="button_create_report" type="object" default_focus="1"/>
142 </form>
143
144=== modified file 'bin/addons/vertical_integration/wizard/wizard_hq_report_ocg.py'
145--- bin/addons/vertical_integration/wizard/wizard_hq_report_ocg.py 2017-02-13 16:32:30 +0000
146+++ bin/addons/vertical_integration/wizard/wizard_hq_report_ocg.py 2017-10-19 09:52:15 +0000
147@@ -38,6 +38,16 @@
148 'fiscalyear_id': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid, time.strftime('%Y-%m-%d'), context=c)
149 }
150
151+ def onchange_instance_id(self, cr, uid, ids, context=None):
152+ """
153+ Resets the period field when another prop. instance is selected.
154+ Covers the case when in HQ the user selects a period closed in a coordo,
155+ and then select another coordo in which the period previously selected is not closed
156+ """
157+ res = {}
158+ res['value'] = {'period_id': False}
159+ return res
160+
161 def button_create_report(self, cr, uid, ids, context=None):
162 if context is None:
163 context = {}

Subscribers

People subscribed via source and target branches