Hi,
How can I set a default value for invoice's account_id using the code?
Thank u
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
Hi,
How can I set a default value for invoice's account_id using the code?
Thank u
Hi Kawtar,
You can override the default_get method to set the default value in account_id field.
@api.model
def default_get(self, fields_list):
res = super(your_class_name, self).default_get(fields_list)
res.update({'account_id': set_default_account_id})
return res
Hope this helps you.
Thanks.
inherit account.invoice module.
override action_move_create(self) method.
and using iml you can add default values like this,
iml.append({
'type': 'dest',
'name': define_name_for_account,
'price': abs(diff),
'account_id': here_define_your_account_id,
'date_maturity': inv.date_due,
'amount_currency': diff_currency and total_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
You can set your account_id with code like this,
'account_id':self.env['account.account'].search([('code', 'ilike', 'your_account_code_goes_here')]).id
UPDATE: solution
@api.model def
default_get(self,vals):
res = super(ordonnance, self).default_get(vals)
code_ids = self.env['account.account'].search([('code','=','default_code')]) if
code_ids: res.update({'account_id':code_ids[0].id})
return res
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się| Powiązane posty | Odpowiedzi | Widoki | Czynność | |
|---|---|---|---|---|
| 
             | 
        
            
                
                3
            
            
             lip 17  
         | 
        5098 | ||
| 
             | 
        
            
                
                3
            
            
             mar 15  
         | 
        5519 | ||
| 
             | 
        
            
                
                3
            
            
             lis 24  
         | 
        5587 | ||
| 
             | 
        
            
                
                0
            
            
             paź 22  
         | 
        2957 | ||
| 
             | 
        
            
                
                1
            
            
             lis 19  
         | 
        5141 |