Merge lp:~openerp-dev/openobject-addons/trunk-bug-1192592-dja into lp:openobject-addons

Proposed by Dharmraj Zala(OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-1192592-dja
Merge into: lp:openobject-addons
Diff against target: 51 lines (+28/-2)
2 files modified
hr_payroll_account/hr_payroll_account.py (+26/-0)
hr_payroll_account/hr_payroll_account_view.xml (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-1192592-dja
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+200063@code.launchpad.net

Description of the change

Hello ,

I've added domain in xml file and also overridden the create and write method of ORM to make sure that in Salary Rule form page accounting ,'Debit Account' and 'Credit Account' can not be an account of type view.

Thanks,
dja.

To post a comment you must log in.

Unmerged revisions

9028. By Dharmraj Zala(OpenERP)

[FIX] debit or credit account should not be of view type

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_payroll_account/hr_payroll_account.py'
2--- hr_payroll_account/hr_payroll_account.py 2013-10-27 12:31:04 +0000
3+++ hr_payroll_account/hr_payroll_account.py 2013-12-26 11:50:16 +0000
4@@ -196,6 +196,32 @@
5 'account_debit': fields.many2one('account.account', 'Debit Account'),
6 'account_credit': fields.many2one('account.account', 'Credit Account'),
7 }
8+
9+ def create(self, cr, uid, vals, context=None):
10+ if context is None:
11+ context = {}
12+ acc_cr = vals.get('account_credit', False)
13+ acc_db = vals.get('account_debit', False)
14+ if acc_db:
15+ if self.pool.get('account.account').browse(cr, uid, acc_db,context=context).type == 'view':
16+ raise osv.except_osv(_('Error!'), _('You Can not set view type account to Debit Account!'))
17+ if acc_cr:
18+ if self.pool.get('account.account').browse(cr, uid, acc_cr,context=context).type == 'view':
19+ raise osv.except_osv(_('Error!'), _('You Can not set view type account to Credit Account!'))
20+ return super(hr_salary_rule, self).create(cr, uid, vals, context=context)
21+
22+ def write(self, cr, uid, ids, vals, context=None):
23+ if context is None:
24+ context = {}
25+ acc_cr = vals.get('account_credit', False)
26+ acc_db = vals.get('account_debit', False)
27+ if acc_db:
28+ if self.pool.get('account.account').browse(cr, uid, acc_db,context=context).type == 'view':
29+ raise osv.except_osv(_('Error!'), _('You Can not set view type account to Debit Account!'))
30+ if acc_cr:
31+ if self.pool.get('account.account').browse(cr, uid, acc_cr,context=context).type == 'view':
32+ raise osv.except_osv(_('Error!'), _('You Can not set view type account to Credit Account!'))
33+ return super(hr_salary_rule, self).write(cr, uid, ids, vals, context=context)
34
35 class hr_contract(osv.osv):
36
37
38=== modified file 'hr_payroll_account/hr_payroll_account_view.xml'
39--- hr_payroll_account/hr_payroll_account_view.xml 2012-11-29 22:26:45 +0000
40+++ hr_payroll_account/hr_payroll_account_view.xml 2013-12-26 11:50:16 +0000
41@@ -25,8 +25,8 @@
42 <xpath expr="/form/notebook/page[@string='Child Rules']" position="after">
43 <page string="Accounting">
44 <group colspan="4">
45- <field name="account_debit" />
46- <field name="account_credit"/>
47+ <field name="account_debit" domain="[('type', '!=', 'view')]" />
48+ <field name="account_credit" domain="[('type', '!=', 'view')]" />
49 <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
50 <field name="account_tax_id"/>
51 </group>

Subscribers

People subscribed via source and target branches

to all changes: