Hi,
In order to have a popup when click in Validate button of account.invoice I have made some changes:
In addons/mymodule/account_invoice.py:
class account_invoice(osv.osv):
_inherit = "account.invoice"
def verify_vat(self, cr, uid, ids, context=None):
""" Verify if the client has nif"""
invoice_obj = self.pool.get('account.invoice')
this = self.browse(cr, uid, ids)[0]
for invoice_vi in invoice_obj.browse(cr,uid,ids):
if invoice_vi.partner_id:
if not invoice_vi.partner_id.vat:
form_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'vi_saft_pt', 'warning_vat_form')
form_id = form_res and form_res[1] or False
#import pdb
#pdb.set_trace()
print "VERIFY_VAT"
return {
'name': _('Warning Vat'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'warning.vat',
'view_id':[form_res and form_res[1] or False],
'target': 'new',
'domain': [],
'type': 'ir.actions.act_window',
'context': context,
}
else:
print "VERIFY_VAT 2return"
return True
account_invoice()
In addons/mymodule/warning_vat_view.xml:
warning.vat.form warning.vat Warning Vat ir.actions.act_window warning.vat form form new Warning Vat form
In addons/mymodule/account_invoice_workflow.xml :
open action_date_assign()
action_move_create()
action_number()
invoice_validate()
verify_vat() function
This code gives me the following error:
Uncaught TypeError: Cannot read property 'view_type' of undefined
http://localhost:8069/web/webclient/js?db=..
If I change the order in addons/mymodule/account_invoice_workflow.xml like this :
open verify_vat()
action_date_assign()
action_move_create()
action_number()
invoice_validate() function
It prints the "VERIFY_VAT" but nothing appears and the invoice is validated.
I had change the code in the return of **verify_vat** but nothing appears...
Thanks
↧