Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
2107 Ansichten
def action_generate_bill(self):
# Assuming you have necessary information for creating the invoice
invoice_data = {
'payment_reference': self.type_id.id, # Replace with the actual partner field in your model
'partner_id': self.user_id.id, # Replace with other necessary fields
# Add more fields as needed
}

# Create a new invoice
new_invoice = self.env['account.move'].create(invoice_data)

# Open the form view of the newly created invoice
action = {
'type': 'ir.actions.act_window',
'res_model': 'account.move',
# 'view_type': 'form',
'view_mode': 'tree,form',
'res_id': new_invoice.id,
}
return action

here is my function here i want to go odoo accounting invoice and want all the field and fucntionality of this view but now when i click on this button it take me to account.move model but i can not found  all the field and also missing add a line option
how i do this 

Avatar
Verwerfen
Beste Antwort

Hi Deen 

Code shows it missing the move_type update the move_type as 'out_invoice' if it is Invoice or as 'in_invoice' if it is a vendor bill 

def action_generate_bill(self):
# Assuming you have necessary information for creating the invoice
invoice_data = {
'payment_reference': self.type_id.id, # Replace with the actual partner field in your model
'partner_id': self.user_id.id, # Replace with other necessary fields
'move_type': 'out_invoice' # if it is a invoice otherwise in_invoice if it is bill
# Add more fields as needed
}
new_invoice = self.env['account.move'].create(invoice_data)


Regards

Avatar
Verwerfen
Autor Beste Antwort

Thanks James its working 

Avatar
Verwerfen