Skip to Content
Menu
This question has been flagged
1 Reply
6028 Views

​Good Night, I am calling a method within another method of the same class. with the option self.env['account.journal'].Method()
I do not get an error, but the view is not shown (it only comes out loading a few seconds and stays on the same page) what could it be?

The action is called from an inherited view(account.account_journal_dashboard_kanban_view). if from the inherited view, change for the specific action. for example: "tipo12()" loads the view without problems. so I conclude that the problem can be the general method (action_crear_documento) Please your support.

​class AccountJournal(models.Model):
    _inherit = "account.journal"

@api.multi
def tipo11(self):
    ref = request.env.ref("account.invoice_form")
    return {
    "type": "ir.actions.act_window",
    "res_model": "account.invoice",
    "target": "self", 
    "view_id": ref.id,
    "view_mode": "form",
    "context": {
    'type': 'out_invoice', 
    'journal_type': 'sale', 
    'type_code': '11', 
    "domain": [('type', 'in', ('out_invoice', 'out_refund')), ('journal_id.invoice_type_code_id', '=', '11')]
    }
@api.multi
def tipo12(self):
    ref = request.env.ref("account.invoice_form")
    return {
    "type": "ir.actions.act_window",
    "res_model": "account.invoice",
    "target": "self",
    "view_id": ref.id,
    "view_mode": "form",
    "context": {
    'type': 'out_invoice',
    'journal_type': 'sale', 
    'type_code': '12',
    "domain": [('type', 'in', ('out_invoice', 'out_refund')), ('journal_id.invoice_type_code_id', '=', '12')]
    }

@api.multi
def action_crear_documento(self):
    if self.type=="sale": 
        if self.invoice_type_code_id=="11":
            self.env['account.journal'].tipo11()
        elif self.invoice_type_code_id=="12": 
            self.env['account.journal'].tipo12()

Avatar
Discard
Best Answer

Okay I am going to change your function.

@api.multi
def action_crear_documento(self):
    if self.type=="sale": 
        if self.invoice_type_code_id=="11":
            return self.env['account.journal'].tipo11()
        elif self.invoice_type_code_id=="12": 
            return self.env['account.journal'].tipo12()

Just returning the results. You consfused in scope of function and result. 

Avatar
Discard
Author

thanks.

Related Posts Replies Views Activity
2
Nov 24
275
1
Oct 24
335
4
Oct 24
327
2
Oct 24
364
2
Dec 24
680