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

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
Abbandona
Risposta migliore

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
Abbandona
Autore

Thank you very much Mr.Waled
It's working

Post correlati Risposte Visualizzazioni Attività
0
nov 22
101
1
apr 24
2534
3
ott 23
8995
1
set 21
3920
1
giu 21
3279