parameters: (self)
return_statement: return product_price_unit
docstring: Helper to get the default price unit based on the product by taking care of the taxes
          set on the product and the fiscal position.
          :return: The price unit.
docstring_summary: Helper to get the default price unit based on the product by taking care of the taxes
          set on the product and the fiscal position.
          :return: The price unit.
docstring_tokens: Helper to get the default price unit based on the product by taking care of the taxes set on the product and the fiscal position . : return : The price unit .
function: def _get_computed_price_unit(self):
          ''' Helper to get the default price unit based on the product by taking care of the taxes
          set on the product and the fiscal position.
          :return: The price unit.
          '''
          self.ensure_one()
  
          if not self.product_id:
              return 0.0
  
          company = self.move_id.company_id
          currency = self.move_id.currency_id
          company_currency = company.currency_id
          product_uom = self.product_id.uom_id
          fiscal_position = self.move_id.fiscal_position_id
          is_refund_document = self.move_id.move_type in ('out_refund', 'in_refund')
          move_date = self.move_id.date or fields.Date.context_today(self)
  
          if self.move_id.is_sale_document(include_receipts=True):
              product_price_unit = self.product_id.lst_price
              product_taxes = self.product_id.taxes_id
          elif self.move_id.is_purchase_document(include_receipts=True):
              product_price_unit = self.product_id.standard_price
              product_taxes = self.product_id.supplier_taxes_id
          else:
              return 0.0
          product_taxes = product_taxes.filtered(lambda tax: tax.company_id == company)
  
          # Apply unit of measure.
          if self.product_uom_id and self.product_uom_id != product_uom:
              product_price_unit = product_uom._compute_price(product_price_unit, self.product_uom_id)
  
          # Apply fiscal position.
          if product_taxes and fiscal_position:
              product_taxes_after_fp = fiscal_position.map_tax(product_taxes)
  
              if set(product_taxes.ids) != set(product_taxes_after_fp.ids):
                  flattened_taxes_before_fp = product_taxes._origin.flatten_taxes_hierarchy()
                  if any(tax.price_include for tax in flattened_taxes_before_fp):
                      taxes_res = flattened_taxes_before_fp.compute_all(
                          product_price_unit,
                          quantity=1.0,
                          currency=company_currency,
                          product=self.product_id,
                          partner=self.partner_id,
                          is_refund=is_refund_document,
                      )
                      product_price_unit = company_currency.round(taxes_res['total_excluded'])
  
                  flattened_taxes_after_fp = product_taxes_after_fp._origin.flatten_taxes_hierarchy()
                  if any(tax.price_include for tax in flattened_taxes_after_fp):
                      taxes_res = flattened_taxes_after_fp.compute_all(
                          product_price_unit,
                          quantity=1.0,
                          currency=company_currency,
                          product=self.product_id,
                          partner=self.partner_id,
                          is_refund=is_refund_document,
                          handle_price_include=False,
                      )
                      for tax_res in taxes_res['taxes']:
                          tax = self.env['account.tax'].browse(tax_res['id'])
                          if tax.price_include:
                              product_price_unit += tax_res['amount']
  
          # Apply currency rate.
          if currency and currency != company_currency:
              product_price_unit = company_currency._convert(product_price_unit, currency, company, move_date)
  
          return product_price_unit
function_tokens: def _get_computed_price_unit ( self ) : self . ensure_one ( ) if not self . product_id : return 0.0 company = self . move_id . company_id currency = self . move_id . currency_id company_currency = company . currency_id product_uom = self . product_id . uom_id fiscal_position = self . move_id . fiscal_position_id is_refund_document = self . move_id . move_type in ( 'out_refund' , 'in_refund' ) move_date = self . move_id . date or fields . Date . context_today ( self ) if self . move_id . is_sale_document ( include_receipts = True ) : product_price_unit = self . product_id . lst_price product_taxes = self . product_id . taxes_id elif self . move_id . is_purchase_document ( include_receipts = True ) : product_price_unit = self . product_id . standard_price product_taxes = self . product_id . supplier_taxes_id else : return 0.0 product_taxes = product_taxes . filtered ( lambda tax : tax . company_id == company ) # Apply unit of measure. if self . product_uom_id and self . product_uom_id != product_uom : product_price_unit = product_uom . _compute_price ( product_price_unit , self . product_uom_id ) # Apply fiscal position. if product_taxes and fiscal_position : product_taxes_after_fp = fiscal_position . map_tax ( product_taxes ) if set ( product_taxes . ids ) != set ( product_taxes_after_fp . ids ) : flattened_taxes_before_fp = product_taxes . _origin . flatten_taxes_hierarchy ( ) if any ( tax . price_include for tax in flattened_taxes_before_fp ) : taxes_res = flattened_taxes_before_fp . compute_all ( product_price_unit , quantity = 1.0 , currency = company_currency , product = self . product_id , partner = self . partner_id , is_refund = is_refund_document , ) product_price_unit = company_currency . round ( taxes_res [ 'total_excluded' ] ) flattened_taxes_after_fp = product_taxes_after_fp . _origin . flatten_taxes_hierarchy ( ) if any ( tax . price_include for tax in flattened_taxes_after_fp ) : taxes_res = flattened_taxes_after_fp . compute_all ( product_price_unit , quantity = 1.0 , currency = company_currency , product = self . product_id , partner = self . partner_id , is_refund = is_refund_document , handle_price_include = False , ) for tax_res in taxes_res [ 'taxes' ] : tax = self . env [ 'account.tax' ] . browse ( tax_res [ 'id' ] ) if tax . price_include : product_price_unit += tax_res [ 'amount' ] # Apply currency rate. if currency and currency != company_currency : product_price_unit = company_currency . _convert ( product_price_unit , currency , company , move_date ) return product_price_unit