Merge lp:~dorian-kemps/unifield-server/US-4151 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4855
Proposed branch: lp:~dorian-kemps/unifield-server/US-4151
Merge into: lp:unifield-server
Diff against target: 70 lines (+38/-0)
3 files modified
bin/addons/delivery_mechanism/delivery_mechanism.py (+1/-0)
bin/addons/msf_profile/data/patches.xml (+4/-0)
bin/addons/msf_profile/msf_profile.py (+33/-0)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-4151
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+342272@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/delivery_mechanism/delivery_mechanism.py'
2--- bin/addons/delivery_mechanism/delivery_mechanism.py 2017-12-14 15:23:34 +0000
3+++ bin/addons/delivery_mechanism/delivery_mechanism.py 2018-03-28 07:26:48 +0000
4@@ -1084,6 +1084,7 @@
5 context=context
6 )
7 out_values['price_unit'] = price_unit
8+ out_values['price_currency_id'] = out_move.price_currency_id.id
9
10 # List the Picking Ticket that need to be created from the Draft Picking Ticket
11 if out_move.picking_id.type == 'out' \
12
13=== modified file 'bin/addons/msf_profile/data/patches.xml'
14--- bin/addons/msf_profile/data/patches.xml 2018-03-15 14:46:24 +0000
15+++ bin/addons/msf_profile/data/patches.xml 2018-03-28 07:26:48 +0000
16@@ -14,6 +14,10 @@
17 <field name="method">us_4407_update_free_lines_ad</field>
18 </record>
19
20+ <record id="us_4151_change_correct_out_currency" model="patch.scripts">
21+ <field name="method">us_4151_change_correct_out_currency</field>
22+ </record>
23+
24 <!-- UF7.3 -->
25 <record id="send_instance_uuid" model="patch.scripts">
26 <field name="method">send_instance_uuid</field>
27
28=== modified file 'bin/addons/msf_profile/msf_profile.py'
29--- bin/addons/msf_profile/msf_profile.py 2018-03-16 09:40:20 +0000
30+++ bin/addons/msf_profile/msf_profile.py 2018-03-28 07:26:48 +0000
31@@ -106,6 +106,39 @@
32 cr.execute(update_free_1)
33 cr.execute(update_free_2)
34
35+ def us_4151_change_correct_out_currency(self, cr, uid, *a, **b):
36+ '''
37+ search the currency_id in FO/IR for each OUT/PICK to set the correct one, doesn't change it if no FO/IR found
38+ '''
39+ company_curr = self.pool.get('res.company').browse(cr, uid, 1, fields_to_fetch=['currency_id']).currency_id.id
40+
41+ move_ids_currencies = {}
42+ cr.execute('''
43+ select m.id, m.price_currency_id, s.procurement_request, pl.currency_id
44+ from stock_move m
45+ left join stock_picking p on (m.picking_id = p.id)
46+ left join sale_order_line sl on (m.sale_line_id = sl.id)
47+ left join sale_order s on (sl.order_id = s.id)
48+ left join product_pricelist pl on (s.pricelist_id = pl.id)
49+ where m.sale_line_id is not null and m.type = 'out' and p.type = 'out' and p.subtype in ('standard', 'picking')
50+ ''')
51+ for x in cr.fetchall():
52+ if x[2]:
53+ currency_id_key = company_curr
54+ else:
55+ currency_id_key = x[3]
56+ if x[1] != currency_id_key:
57+ if currency_id_key in move_ids_currencies:
58+ move_ids_currencies[currency_id_key].append(x[0])
59+ else:
60+ move_ids_currencies.update({currency_id_key: [x[0]]})
61+
62+ for currency_id in move_ids_currencies:
63+ cr.execute('''update stock_move set price_currency_id = %s where id in %s'''
64+ , (currency_id, tuple(move_ids_currencies[currency_id])))
65+
66+ return True
67+
68 # UF7.3
69 def flag_pi(self, cr, uid, *a, **b):
70 cr.execute('''select distinct i.id, p.default_code from

Subscribers

People subscribed via source and target branches