Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Sales

Entity: sale.order

Compute Method: _compute_fiscal_position_id

View 19.0 View 20.0
Inputs Method Outputs
  • partner_id
  • fiscal_position_id
  • fiscal_position_id.id
  • company_id
  • company_id.id
  • partner_id.id
  • partner_shipping_id
  • partner_shipping_id.id
  • order_line
- """
-         Trigger the change of fiscal position when the shipping address is modified.
-         """
cache = {}
for order in self:
            if not order.partner_id:
                order.fiscal_position_id = False
                continue
-             fpos_id_before = order.fiscal_position_id.id
            key = (order.company_id.id, order.partner_id.id, order.partner_shipping_id.id)
            if key not in cache:
-                 cache[key] = self.env['account.fiscal.position'].with_company(
-                     order.company_id
-                 )._get_fiscal_position(order.partner_id, order.partner_shipping_id).id
-             if fpos_id_before != cache[key] and order.order_line:
-                 order.show_update_fpos = True
+                 cache[key] = (
+                     self
+                     .env["account.fiscal.position"]
+                     .with_company(order.company_id)
+                     ._get_fiscal_position(order.partner_id, order.partner_shipping_id)
+                     .id
+                 )
            order.fiscal_position_id = cache[key]
  • fiscal_position_id
  • show_update_fpos

Back to entity