Skip to Content
Menu
This question has been flagged

I created a button that creates an invoice in the invoice module according to data from my Custom module

When I press the button, the data appears in the database, but does not appear in the view

What is the reason for that? 

my code :

    defcreate_invoice(self):
        vals={   
        'name':'samer',   
        'partner_id':self.vendor_id.id,   
        'invoice_date':date.today(),     
      'state':'draft',       
    'invoice_line_ids': [(0, 0, {   
            'price_unit': self.product_id.list_price,   
            'quantity': 1.0,           
    'discount': 0.0,               
'product_id': self.product_id.name, 
          })]        }     
  self.update({           
'state': '2', 
      })   
    return self.env['account.move'].create(vals)
Avatar
Discard
Best Answer

It will not shown in Invoices but it will shown in journal entry because the move_type is not set and the default value is entry. it should be out_invoice for sales invoices and in_invoice for purchase bill.


The product_id should get the id value not the name 'product_id': self.product_id.id


    vals={    

'name':'samer',

'partner_id':self.vendor_id.id,

'invoice_date':date.today(),

'move_type': 'out_invoice',

'invoice_line_ids': [(0, 0, {

'price_unit': self.product_id.list_price,

'quantity': 1.0,

'discount': 0.0,

'product_id': self.product_id.id,

'name': self.product_id.name

})]

}  
Avatar
Discard
Author

Thank you very much Mr.Waled
It's working

Related Posts Replies Views Activity
0
Nov 22
101
1
Apr 24
315
3
Oct 23
6406
1
Sep 21
2028
1
Jun 21
1930