Merge lp:~unifield-team/unifield-wm/us_404 into lp:unifield-wm

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~unifield-team/unifield-wm/us_404
Merge into: lp:unifield-wm
Diff against target: 88 lines (+37/-2)
4 files modified
msf_instance/add_instance.py (+27/-1)
msf_profile/data/patches.xml (+4/-0)
msf_profile/msf_profile.py (+5/-0)
register_accounting/report/cash_inventory.rml (+1/-1)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/us_404
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+263881@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

2543. By Stephane Codazzi <email address hidden>

US_404: Deduplicate cashbox line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'msf_instance/add_instance.py'
2--- msf_instance/add_instance.py 2015-04-02 15:09:28 +0000
3+++ msf_instance/add_instance.py 2015-07-06 10:22:07 +0000
4@@ -417,6 +417,22 @@
5 'instance_id': fields.many2one('msf.instance', 'Proprietary Instance'),
6 }
7
8+ #us-404: Remove all duplicated lines
9+ def remove_duplicates(self, cr, uid, context=None):
10+ domain = [('starting_id', '>', 0)]
11+ ids = self.search(cr, uid, domain, order="id DESC", context=context)
12+ objs = self.browse(cr, uid, ids, context=context)
13+ unlink_ids = []
14+ for obj in objs:
15+ if obj.id not in unlink_ids:
16+ duplicate_domain = [('starting_id', '=', obj.starting_id),
17+ ('pieces', '=', obj.pieces),
18+ ('id', '<', obj.id)]
19+ duplicate_ids = self.search(cr, uid, duplicate_domain,
20+ context=context)
21+ unlink_ids = unlink_ids + duplicate_ids
22+ return self.unlink(cr, uid, unlink_ids, context=context)
23+
24 def create(self, cr, uid, vals, context=None):
25 if 'starting_id' in vals:
26 register = self.pool.get('account.bank.statement').read(cr, uid, vals['starting_id'], ['instance_id'], context=context)
27@@ -424,7 +440,17 @@
28 elif 'ending_id' in vals:
29 register = self.pool.get('account.bank.statement').read(cr, uid, vals['ending_id'], ['instance_id'], context=context)
30 vals['instance_id'] = register.get('instance_id')[0]
31- return super(account_cashbox_line, self).create(cr, uid, vals, context=context)
32+ # US-404: If line already exist with the same starting_id and piece
33+ ids = None
34+ if 'starting_id' in vals and 'pieces' in vals:
35+ domain = [('starting_id', '=', vals['starting_id']),
36+ ('pieces', '=', vals['pieces'])]
37+ ids = self.search(cr, uid, domain, context=context)
38+ if ids:
39+ return self.write(cr, uid, ids[0], vals, context=context)
40+ else:
41+ return super(account_cashbox_line, self).create(cr, uid, vals,
42+ context=context)
43
44 def write(self, cr, uid, ids, vals, context=None):
45 if 'starting_id' in vals:
46
47=== modified file 'msf_profile/data/patches.xml'
48--- msf_profile/data/patches.xml 2015-05-22 14:25:13 +0000
49+++ msf_profile/data/patches.xml 2015-07-06 10:22:07 +0000
50@@ -6,5 +6,9 @@
51 <field name="method">update_us_133</field>
52 </record>
53
54+ <record id="us_404_patch" model="patch.scripts">
55+ <field name="method">update_us_404</field>
56+ </record>
57+
58 </data>
59 </openerp>
60
61=== modified file 'msf_profile/msf_profile.py'
62--- msf_profile/msf_profile.py 2015-05-27 10:34:50 +0000
63+++ msf_profile/msf_profile.py 2015-07-06 10:22:07 +0000
64@@ -51,6 +51,11 @@
65 getattr(model_obj, method)(cr, uid, *a, **b)
66 self.write(cr, uid, [ps['id']], {'run': True})
67
68+ def update_us_404(self, cr, uid, *a, **b):
69+ obj = self.pool.get('account.cashbox.line')
70+ print "starting patch"
71+ obj.remove_duplicates(cr, uid, context={})
72+
73 def update_us_133(self, cr, uid, *a, **b):
74 p_obj = self.pool.get('res.partner')
75 po_obj = self.pool.get('purchase.order')
76
77=== modified file 'register_accounting/report/cash_inventory.rml'
78--- register_accounting/report/cash_inventory.rml 2014-10-03 12:40:50 +0000
79+++ register_accounting/report/cash_inventory.rml 2015-07-06 10:22:07 +0000
80@@ -399,7 +399,7 @@
81 <font color="white"> </font>
82 </para>
83
84- <blockTable style="Table100">
85+ <blockTable style="Table100">
86 <tr>
87 <td>
88 <para style="P7">Comments:</para>

Subscribers

People subscribed via source and target branches