Merge lp:~cv.clearcorp/openerp-ccorp-addons/7.0-fix_discount_invoice into lp:openerp-ccorp-addons/7.0

Proposed by Carlos Vásquez (ClearCorp)
Status: Merged
Merged at revision: 893
Proposed branch: lp:~cv.clearcorp/openerp-ccorp-addons/7.0-fix_discount_invoice
Merge into: lp:openerp-ccorp-addons/7.0
Diff against target: 31 lines (+12/-10)
1 file modified
account_invoice_limit_discount/account_invoice_inherit.py (+12/-10)
To merge this branch: bzr merge lp:~cv.clearcorp/openerp-ccorp-addons/7.0-fix_discount_invoice
Reviewer Review Type Date Requested Status
ClearCorp drivers Pending
Review via email: mp+224904@code.launchpad.net

Description of the change

[IMP] Improve invoice_validate function. Add restriction: Only discount restriction counts for customer invoices

To post a comment you must log in.
893. By Carlos Vásquez (ClearCorp)

[FIX] Fix tab in account_invoice_inherit.py file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_invoice_limit_discount/account_invoice_inherit.py'
2--- account_invoice_limit_discount/account_invoice_inherit.py 2014-06-11 20:38:15 +0000
3+++ account_invoice_limit_discount/account_invoice_inherit.py 2014-06-27 22:22:04 +0000
4@@ -31,14 +31,16 @@
5 #Check if user is in group 'group_account_invoice_limit_discount'
6 is_in_group = self.pool.get('res.users').has_group(cr, uid, 'account_invoice_limit_discount.group_account_invoice_limit_discount')
7
8- if not is_in_group:
9- #Get company for user currently logged
10- company_user = self.pool.get('res.users').browse(cr, uid, uid).company_id
11- max_company_discount = company_user.max_discount
12-
13- for invoice in self.browse(cr, uid, ids, context=context):
14- for line in invoice.invoice_line:
15- if line.discount > max_company_discount:
16- raise osv.except_osv(_("Discount Exceeded!"), _("The discount of invoice exceeds the limit of maximum discount %s of the company") % (str(max_company_discount)))
17-
18+ for invoice in self.browse(cr, uid, ids, context=context):
19+ if invoice.type == 'out_invoice' or invoice.type == 'out_refund':
20+ if not is_in_group:
21+ #Get company for user currently logged
22+ company_user = self.pool.get('res.users').browse(cr, uid, uid).company_id
23+ max_company_discount = company_user.max_discount
24+
25+ for invoice in self.browse(cr, uid, ids, context=context):
26+ for line in invoice.invoice_line:
27+ if line.discount > max_company_discount:
28+ raise osv.except_osv(_("Discount Exceeded!"), _("The discount of invoice exceeds the limit of maximum discount %s of the company") % (str(max_company_discount)))
29+
30 return super(accountInvoiceinherit, self).invoice_validate(cr, uid, ids, context=context)
31\ No newline at end of file

Subscribers

People subscribed via source and target branches