Merge lp:~unifield-team/unifield-wm/us-655 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2730
Proposed branch: lp:~unifield-team/unifield-wm/us-655
Merge into: lp:unifield-wm
Diff against target: 66 lines (+38/-2)
2 files modified
consumption_calculation/consumption_calculation.py (+36/-0)
consumption_calculation/consumption_view.xml (+2/-2)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/us-655
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+283072@code.launchpad.net
To post a comment you must log in.
lp:~unifield-team/unifield-wm/us-655 updated
2704. By Quentin THEURET @Amaris

Merge latest trunk

2705. By Quentin THEURET @Amaris

US-655 [FIX] Recompute the name of the consumer location in the Real consumption report when the consumer location is selected or changed
US-655 [FIX] Recompute the name of the consumer location or activity in the Real consumption report when the name of the location is changed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'consumption_calculation/consumption_calculation.py'
2--- consumption_calculation/consumption_calculation.py 2015-10-08 14:59:02 +0000
3+++ consumption_calculation/consumption_calculation.py 2016-01-21 10:02:15 +0000
4@@ -131,11 +131,47 @@
5 res[obj.id] = True
6 return res
7
8+ def _get_stock_location(self, cr, uid, ids, context=None):
9+ """
10+ Return the list of real consumption reports to update
11+ """
12+ return self.pool.get('real.average.consumption').search(cr, uid, [
13+ '|',
14+ ('cons_location_id', 'in', ids),
15+ ('activity_id', 'in', ids),
16+ ], context=context)
17+
18+ def _get_act_name(self, cr, uid, ids, fields, arg, context=None):
19+ """
20+ Set the activity name when the activity_id is changed
21+ """
22+ if context is None:
23+ context = {}
24+
25+ if isinstance(ids, (int, long)):
26+ ids = [ids]
27+
28+ res = {}
29+ for rac in self.browse(cr, uid, ids, context=context):
30+ res[rac.id] = {}
31+ res[rac.id]['activity_name'] = rac.activity_id and rac.activity_id.name or ''
32+ res[rac.id]['cons_location_name'] = rac.cons_location_id and rac.cons_location_id.name or ''
33+
34+ return res
35+
36 _columns = {
37 'name': fields.char(size=64, string='Reference'),
38 'creation_date': fields.datetime(string='Creation date', required=1),
39 'cons_location_id': fields.many2one('stock.location', string='Consumer location', domain=[('usage', '=', 'internal')], required=True),
40+ 'cons_location_name': fields.function(_get_act_name, method=True, type='char', string='Consumer location Name', readonly=True, size=128, multi='loc_name', store={
41+ 'real.average.consumption': (lambda obj, cr, uid, ids, c={}: ids, ['cons_location_id'], 10),
42+ 'stock.location': (_get_stock_location, ['name'], 20),
43+ },),
44 'activity_id': fields.many2one('stock.location', string='Activity', domain=[('usage', '=', 'customer')], required=1),
45+ 'activity_name': fields.function(_get_act_name, method=True, type='char', string='Activity Name', readonly=True, size=128, multi='loc_name', store={
46+ 'real.average.consumption': (lambda obj, cr, uid, ids, c={}: ids, ['activity_id'], 10),
47+ 'stock.location': (_get_stock_location, ['name'], 20),
48+ },),
49 'period_from': fields.date(string='Period from', required=True),
50 'period_to': fields.date(string='Period to', required=True),
51 'sublist_id': fields.many2one('product.list', string='List/Sublist', ondelete='set null'),
52
53=== modified file 'consumption_calculation/consumption_view.xml'
54--- consumption_calculation/consumption_view.xml 2015-05-18 12:40:26 +0000
55+++ consumption_calculation/consumption_view.xml 2016-01-21 10:02:15 +0000
56@@ -102,8 +102,8 @@
57 <field name="arch" type="xml">
58 <tree string="Real consumption reports">
59 <field name="name" />
60- <field name="cons_location_id" />
61- <field name="activity_id" />
62+ <field name="cons_location_name" string="Consumer location" />
63+ <field name="activity_name" string="Activity" />
64 <field name="period_from" />
65 <field name="period_to" />
66 <field name="nb_lines" />

Subscribers

People subscribed via source and target branches