Merge lp:~vauxoo/openerp-venezuela-localization/ovl70-invoice-cancel-kty into lp:openerp-venezuela-localization

Proposed by Katherine Zaoral (Vauxoo)
Status: Merged
Merged at revision: 856
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/ovl70-invoice-cancel-kty
Merge into: lp:openerp-venezuela-localization
Diff against target: 44 lines (+18/-10)
1 file modified
l10n_ve_fiscal_book/model/invoice.py (+18/-10)
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/ovl70-invoice-cancel-kty
Reviewer Review Type Date Requested Status
hbto [Vauxoo] http://www.vauxoo.com Approve
Review via email: mp+167372@code.launchpad.net

Description of the change

[IMP] cancel invoice process now take in count the fiscal book management (add exception)

To post a comment you must log in.
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ve_fiscal_book/model/invoice.py'
2--- l10n_ve_fiscal_book/model/invoice.py 2013-04-25 16:22:59 +0000
3+++ l10n_ve_fiscal_book/model/invoice.py 2013-06-04 19:08:29 +0000
4@@ -24,9 +24,10 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 ###############################################################################
7 from openerp.osv import osv, fields
8-
9-
10-class inherited_invoice(osv.osv):
11+from openerp.tools.translate import _
12+
13+
14+class account_invoice(osv.osv):
15 _inherit = "account.invoice"
16
17 _columns = {
18@@ -36,12 +37,19 @@
19 'issue_fb_id': fields.many2one('fiscal.book', 'Fiscal Book',
20 help='Fiscal Book where this invoice \
21 needs to be add'),
22- # TODO: THIS FIELD TO BE CHANGED TO A STORABLE FUNCTIONAL FIELD
23- # CHANGE EVEN FROM boolean to selection
24- 'fb_submitted': fields.boolean('Fiscal Book Submitted?',
25- help='Indicates if this invoice is in \
26- a Fiscal Book which has being already \
27- submitted to the statutory institute'),
28 }
29
30-inherited_invoice()
31+ def action_cancel(self, cr, uid, ids, context=None):
32+ """ Verify first in the invoice have a fiscal book associated and if
33+ the sate of the book is in cancel. """
34+ context = context or {}
35+ for inv_brw in self.browse(cr, uid, ids, context=context):
36+ if not inv_brw.fb_id or (inv_brw.fb_id and inv_brw.fb_id.state == 'cancel'):
37+ super(account_invoice, self).action_cancel(cr, uid, ids,
38+ context=context)
39+ else:
40+ raise osv.except_osv(_("Error!"),
41+ _("You can't cancel an invoice that is loaded in a processed"
42+ "Fiscal Book. You need to go to Fiscal Book and set the book"
43+ " to Draft. Then you could be able to cancel the invoice."))
44+ return True