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

Proposed by jftempo
Status: Merged
Merged at revision: 5111
Proposed branch: lp:~julie-w/unifield-server/US-5179
Merge into: lp:unifield-server
Diff against target: 61 lines (+28/-0)
2 files modified
bin/addons/account/wizard/account_subscription_generate.py (+6/-0)
bin/addons/account_subscription/account_model.py (+22/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-5179
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+356380@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/account/wizard/account_subscription_generate.py'
2--- bin/addons/account/wizard/account_subscription_generate.py 2016-08-31 15:23:13 +0000
3+++ bin/addons/account/wizard/account_subscription_generate.py 2018-10-10 07:25:21 +0000
4@@ -38,6 +38,7 @@
5 mod_obj = self.pool.get('ir.model.data')
6 act_obj = self.pool.get('ir.actions.act_window')
7 sub_line_obj = self.pool.get('account.subscription.line')
8+ account_obj = self.pool.get('account.account')
9 moves_created=[]
10 for data in self.read(cr, uid, ids, context=context):
11 cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['date'],))
12@@ -54,6 +55,11 @@
13 credit = 0.0
14 debit = 0.0
15 for line in acc_model_lines:
16+ # Check account/Third Party compatibility
17+ account_id = line.account_id.id
18+ partner_id = line.partner_id and line.partner_id.id or False
19+ account_obj.check_type_for_specific_treatment(cr, uid, [account_id], partner_id=partner_id, context=context)
20+ account_obj.is_allowed_for_thirdparty(cr, uid, [account_id], partner_id=partner_id, raise_it=True, context=context)
21 credit += line.credit or 0.0
22 debit += line.debit or 0.0
23 if abs(debit - credit) > 10 ** -4:
24
25=== modified file 'bin/addons/account_subscription/account_model.py'
26--- bin/addons/account_subscription/account_model.py 2017-11-21 17:07:56 +0000
27+++ bin/addons/account_subscription/account_model.py 2018-10-10 07:25:21 +0000
28@@ -137,11 +137,33 @@
29 }
30
31 def create(self, cr, uid, vals, context=None):
32+ if context is None:
33+ context = {}
34+ account_obj = self.pool.get('account.account')
35 model = self.pool.get('account.model').browse(cr, uid, vals['model_id'], context=context)
36 # just add the next line
37 vals['sequence'] = len(model.lines_id) + 1
38+ # Check account/Third Party compatibility
39+ if vals.get('account_id', False) and 'partner_id' in vals:
40+ account_obj.check_type_for_specific_treatment(cr, uid, [vals['account_id']],
41+ partner_id=vals.get('partner_id', False), context=context)
42+ account_obj.is_allowed_for_thirdparty(cr, uid, [vals['account_id']], partner_id=vals.get('partner_id', False),
43+ raise_it=True, context=context)
44 return super(account_model_line, self).create(cr, uid, vals, context=context)
45
46+ def write(self, cr, uid, ids, vals, context=None):
47+ if context is None:
48+ context = {}
49+ account_obj = self.pool.get('account.account')
50+ res = super(account_model_line, self).write(cr, uid, ids, vals, context=context)
51+ # Check account/Third Party compatibility
52+ for line in self.browse(cr, uid, ids, fields_to_fetch=['account_id', 'partner_id'], context=context):
53+ account_id = line.account_id.id
54+ partner_id = line.partner_id and line.partner_id.id or False
55+ account_obj.check_type_for_specific_treatment(cr, uid, account_id, partner_id=partner_id, context=context)
56+ account_obj.is_allowed_for_thirdparty(cr, uid, account_id, partner_id=partner_id, raise_it=True, context=context)
57+ return res
58+
59 def button_analytic_distribution(self, cr, uid, ids, context=None):
60 """
61 Launch analytic distribution wizard on an invoice line

Subscribers

People subscribed via source and target branches