Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4406 Visualizzazioni

I have added project_id to the account.invoice and invoice_ids to project.project I want to see the related invoices in the ProjectForm view

So far I have added:

<button name="action_view_invoice"
type="object"
class="oe_stat_button"
icon="fa-pencil-square-o"
attrs="{'invisible': [('invoice_count', '=', 0)]}">
<field name="invoice_count" widget="statinfo" string="Invoices"/>
</button>

 And:

@api.multi
def action_view_invoice(self):
invoice_ids = self.mapped('invoice_ids')
imd = self.env['ir.model.data']
action = imd.xmlid_to_object('account.action_invoice_tree1')
list_view_id = imd.xmlid_to_res_id('account.invoice_tree')
form_view_id = imd.xmlid_to_res_id('account.invoice_form')
result = {
'name': action.name,
'help': action.help,
'type': action.type,
'views': [[list_view_id, 'tree'], [form_view_id, 'form'], [False, 'graph'], [False, 'kanban'], [False, 'calendar'], [False, 'pivot']],
'target': action.target,
'context': action.context,
'res_model': action.res_model,
}
if len(invoice_ids) > 1:
result['domain'] = "[('id','in',%s)]" % invoice_ids.ids
elif len(invoice_ids) == 1:
result['views'] = [(form_view_id, 'form')]
result['res_id'] = invoice_ids.ids[0]
else:
result = {'type': 'ir.actions.act_window_close'}
return result


So far it works, now the problem is when I press the button and see the invoices related to the project if I chose to create new invoice it doesn't automatically sets the default project to the current one. I would like to have the same behavior like  in Contacts when you go to Sales it shows you the sales related to the contact AND creating new sale automatically sets the customer to the current one

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
ago 25
197
1
ago 25
85
0
ago 25
123
1
ago 25
301
3
ago 25
300