Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
3107 Переглядів

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)
Аватар
Відмінити
Найкраща відповідь

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

})]

}  
Аватар
Відмінити
Автор

Thank you very much Mr.Waled
It's working

Related Posts Відповіді Переглядів Дія
0
лист. 22
101
1
квіт. 24
2536
3
жовт. 23
8998
Manual Invoice Sequence Вирішено
1
вер. 21
3922
1
черв. 21
3282