20% OFF UNTIL THE END OF THE YEAR Use Code: OFF20 for 20% Off! (excluding customizations and support packages)
I encounter the “One line has different Included In Price parameter in Taxes” error when importing a new order. Why?

I encounter the “One line has different Included In Price parameter in Taxes” error when importing a new order. Why?

image-20240301-133946.png

This error message is self-explanatory – the issue arises from having taxes with varying “Included In Price” settings within the order. Upon reviewing the Odoo Taxes list, it becomes apparent that some of the taxes have this checkbox enabled, while others do not:

image-20240301-133953.png

Regrettably, pinpointing the problematic product or order line is challenging but achievable. We’ve developed a specific code snippet to assist in diagnosing and locating the precise tax or product requiring correction.

The initial step involves creating a new Scheduled Action (this menu is solely visible in debug mode). Specify “Sale Integration” as Model and deactivate the Active checkbox to prevent automatic execution of this action:

image-20240301-134026.png

Subsequently, populate the “Python Code” tab with the provided code snippet:

si = model.browse([1])
input_file = env['sale.integration.input.file'].browse([565])

parsed_order = si.adapter.parse_order(input_file.to_dict())

taxes = []
products_without_taxes = []
for row in parsed_order['lines']:
  product_id = row['product_id']
  
  if row['taxes']:
    for tax_id in row['taxes']:
      external_tax = env['integration.account.tax.external'].get_external_by_code(si, tax_id)
      taxes.append((external_tax.mapping_record.tax_id, 'Order Line Tax'))
  else:
    product = env['product.product'].from_external(si, row['product_id'], raise_error=False)
    products_without_taxes.append(product)

policy = si.behavior_on_empty_tax
if policy == 'set_special_tax':
  taxes.append((si.zero_tax_id, 'Special Zero Tax'))
elif policy == 'take_from_product':
  for product in products_without_taxes:
    for tax in product.taxes_id:
      taxes.append((tax, 'Odoo Product Tax'))

debug_info = 'Behavior on Empty Taxes is {}\n\n'.format(policy)

for (tax, tax_type) in taxes:
  debug_info += '{} tax ({}) has price_include = {}\n'.format(tax.name, tax_type, tax.price_include)

raise UserError(debug_info)

Please remember to substitute <your integration ID> and <your external order data ID> with their respective real IDs:

image-20240301-134046.pngimage-20240301-134054.png

Execute this script, which will yield a message similar to what’s shown below:

image-20240301-134102.png

If differing price_include values are observed, adjustments need to be made in the taxes section by setting them accordingly. For instance, based on the screenshot above, it’s likely necessary to enable the “Included in Price” checkbox for 10% taxes.

Please note that there may be taxes on delivery or discounted products used in orders. These cases aren’t covered by the script, so you will need to check them manually.

If you still have the same issue, don’t hesitate to contact our support team: https://support.ventor.tech/

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *