Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
9352 Vizualizări

Hii,

From a custom module I am passing the following default values to account.invoice when clicking create button.
Custom Field Id
Vendor
Journal

Following is the code how I passing default values in the context and it set default values successfully to account.invoice.

@api.multi
def show_insurance_invoices(self):
return {
'name': _('Insurance Bills'),
'domain': [('shipment_id', '=', self.id), ('journal_id', '=', self.insurance_journal_id.id)],
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'type': 'ir.actions.act_window',
'context': {
'default_shipment_id': self.id,
'default_journal_id': self.insurance_journal_id.id,
'default_partner_id': self.insurance_partner_id.id
},
}

Is there a way to pass default product id or some other values in the above context and line auto created and values assigned on account.invoice.line model?

Imagine profil
Abandonează
Autor Cel mai bun răspuns

I solved it the different way. 

Instead of passing the default values from my custom module to account.invoice.
I created new button in my custom module called Create Insurance Bill.
In this method I created new invoice object and passed all header and lines info. Job beautifully done.

Here is the code..

@api.multi
    def create_insurance_bill(self):
result = self.env['account.invoice'].create({ 'partner_id': self.insurance_partner_id.id, 'shipment_id': self.id, 'name': 'Insurance Bill', 'type': 'in_invoice', 'origin': self.name, 'journal_id': self.insurance_journal_id.id,
'invoice_line_ids': [(0, 0, {
'name': self.insurance_product_id.name,
'origin': self.name,
'account_id': self.insurance_product_id.property_account_expense_id.id,
'price_unit': self.insurance_amount,
'quantity': 1.0,
'discount': 0.0,
'uom_id': self.insurance_product_id.uom_id.id,
'product_id': self.insurance_product_id.id,
})],
})
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
feb. 22
2273
0
mar. 15
3280
1
nov. 19
8079
0
mar. 18
4573
1
mar. 24
2890