OCA / pos

GNU Affero General Public License v3.0
284 stars 605 forks source link

pos_order_to_sale_order Fiscal Position applied at Header but not at OrderLines #1107

Closed xmorejon closed 11 months ago

xmorejon commented 11 months ago

Module

pos_order_to_sale_order "name": "PoS Order To Sale Order", "version": "16.0.1.0.7",

Describe the bug

Some customers have a Fiscal Position ("Recargo de Equivalencia") which should result on a +5.2% taxes on top of the Spanish VAT(21%).

Fiscal Positions is correctly set into the Sales Order/Other Info/Fiscal Position Field, but the Order Lines do not get automatically the 5.2% tax.

If Sales Order is invoiced directly, the Invoice will be wrong and will not reflect its Fiscal Position. I need to compute again the taxes manually prior to invoice it, to have it right.

To Reproduce

Steps to reproduce the behavior:

  1. Set into Point Of Sale configuration the Flag "Flexible Taxes" and add "Recargo de Equivalencia" in the "Allowed" ones:

    image
  2. Generate a Sales Order. (As the Selected customer has a predefined "Fiscal Position", the POS is applying it already. That is Correct:

    image
  3. Sales Order has inherited the Fiscal Positions accordingly (correct):

image
  1. Sales Order lines only have the 21% VAT but not the additional 5.2% corresponding to the Fiscal Position: image

Expected behavior Sales Order lines should have included the Fiscal Position condition:

image

I am able to get those lines, if running the Method: action_update_taxes (Pressing "Update Taxes)

image

About Me **

Xavier M from Barcelona Administrator of Odoo for small family business. Years of experience in different programming languages, but learning Odoo since 4 months. Running Odoo 16.0 Community version in own Virtual Machine (Ubuntu 22LTS, NGINX)

Not sure if this is a BUG or a missing configuration. Any Comment or Workaround is welcome! (I.e. automatically force a re-compute Taxes prior to generate the Invoice. ¿Is such an automated trigger posible?)

T H A N K Y O U!

legalsylvain commented 11 months ago

Hi. @xmorejon. As far as I understand, the taxes of the sale order lines, are the taxes on the pos order lines. See : https://github.com/OCA/pos/blob/16.0/pos_order_to_sale_order/models/sale_order_line.py#L19

Are the pos order line correctly set ?

thanks !

xmorejon commented 11 months ago

Hi,

The POS Order Line are not correctly set:

At Product Info / line Level it is not displaying the 0,234€ in the POS Order Line:

image

But on the Total it is correctly displayed:

image

Also if instead of generating the Sales Order, we do the Payment on the POS, the receipt will be correctly built:

image

Could it be that the Point of Sale does a recomputing of the taxes in a later stage, so while preparing Sales Order Lines from the POS Order Lines this Fiscal Position is wrong? https://github.com/OCA/pos/blob/16.0/pos_order_to_sale_order/models/sale_order_line.py#L19

Thank you so much for looking into it!

legalsylvain commented 11 months ago

Well. Could add a screenshot of the pos order taxes in the back-office ?

xmorejon commented 11 months ago

Apologies not sure if I follow you:

image

This one corresponds to the receipt of the screenshot Order 00172-001-001. Note that the Taxes are CORRECT.

Sales Order screenshot:

image

No available POS Order: Order 00167-001-0001

image

But corresponding Sales Order in the back-office do miss the Fiscal Position items:

image

Should I look somewhere else? Merci Sylvain!

xmorejon commented 11 months ago

Hi again!

Forcing a recompute of Taxes, did the trick and seems to fix the issue! :)

image

And now the Sales Order has the correct Fiscal Position included:

image

As mentioned, I am pretty new to ODOO, and not sure if this way of fixing the issue is correct. Therefore, I would wait for feedback and not suggest this pull request.

Thank you,

Xavier Morejon

legalsylvain commented 11 months ago

could you add a print(order_data) here : https://github.com/OCA/pos/blob/16.0/pos_order_to_sale_order/models/sale_order.py#L13 ? and put her the result. thanks !

xmorejon commented 11 months ago

Hi,

Here you go. (Order with 2 lines):

{'name': 'Order 00188-001-0001', 'amount_paid': 0, 'amount_total': 11.36, 'amount_tax': 2.36, 'amount_return': 0, 'lines': [[0, 0, {'qty': 1, 'price_unit': 4.5, 'price_subtotal': 4.5, 'price_subtotal_incl': 5.68, 'discount': 0, 'product_id': 62, 'tax_ids': [[6, False, [1]]], 'id': 1, 'pack_lot_ids': [], 'description': '', 'full_product_name': 'B-0001', 'price_extra': 0, 'price_manually_set': False, 'price_automatically_set': False}], [0, 0, {'qty': 1, 'price_unit': 4.5, 'price_subtotal': 4.5, 'price_subtotal_incl': 5.68, 'discount': 0, 'product_id': 78, 'tax_ids': [[6, False, [1]]], 'id': 2, 'pack_lot_ids': [], 'description': '', 'full_product_name': 'BC-0002', 'price_extra': 0, 'price_manually_set': False, 'price_automatically_set': False}]], 'statement_ids': [], 'pos_session_id': 190, 'pricelist_id': 3, 'partner_id': 11157, 'user_id': 2, 'uid': '00188-001-0001', 'sequence_number': 1, 'creation_date': '2023-12-10T08:50:06.942Z', 'fiscal_position_id': 6, 'server_id': False, 'to_invoice': False, 'to_ship': False, 'is_tipped': False, 'tip_amount': 0, 'access_token': '3eb2f19d-8a81-4299-a0ff-e41ee1dce4df'}

image

So the Subtotal is right -> 'price_subtotal_incl': 5.68 But there is only one of the TaxID's (corresponding to the 21%) -> 'tax_ids': [[6, False, [1]]]

image

Thank you. Xavier

legalsylvain commented 11 months ago

Hi. At first glance, i think the problem is not in pos order to sale order module. The module just use export to JSON function that looks to return bad résult

https://github.com/OCA/pos/blob/16.0/pos_order_to_sale_order/static/src/js/CreateOrderPopup.js#L49

Investigation should be done over there.

Thanks !

xmorejon commented 11 months ago

Thank you Sylvain! I believe you are right. As the issue looks to be out of this module, I will close the reported issue.

Will look further into:

image

But might also apply the "dirty" fix of recomputing the taxes in alternate version of the module. I really need the Fiscal positions to give expected outcome!

Thank you very much. Great job! Xavier