I tried this piece of code but it does not work:
fiscal_position_id = fields.Many2one(
'account.fiscal.position',
string='Fiscal Position',
default=lambda self: self.env['account.fiscal.position'].search([('id','=',2)])
)
I tried this piece of code but it does not work:
fiscal_position_id = fields.Many2one(
'account.fiscal.position',
string='Fiscal Position',
default=lambda self: self.env['account.fiscal.position'].search([('id','=',2)])
)
Copyright © 2021 Jogjafile Inc.
The default fiscal position is set then updated when the Customer or the Delivery Address value is changed and that's why your code didn't work
You can set the fiscal position in the customer or the delivery address form and Odoo will set it automatically for you on the sale order.
if the fiscal position is not defined for the customer or for the delivery address Odoo will try to retrieve the fiscal position by region (customer or delivery address) and the Detect Automatically should be checked on the fiscal position.
For more details check the user documentation on Taxes/Fiscal Positions