Files
odoo_source/addons/purchase_requisition/tests
lase@odoo.com adb2cd2b05 [FIX] purchase_requisition: compute taxes for alternative PO creation
Steps to reproduce:

- Create a request for quotation for a product with set vendor Taxes
- Create an alternative purchase order from that RFQ with Copy Product

Current Behavior:

The purchase order line of the PO associated with the created
alternative does not compute the taxes.

Expected behavior:

The taxes should be computed in the same way as if the PO was created
manually and then linked to the alternatives.

Cause of the issue:

When creating a PO manually, the taxes of each purchase order line
are computed when the product is set during the call of the
`onchange_product_id` onchange method:
https://github.com/odoo/odoo/blob/64c13193ae0fe23eb1b426f5bbcd8531e9a40967/addons/purchase/models/purchase.py#L1221
https://github.com/odoo/odoo/blob/7ed0a773b6e0711b127f236ce665c35202d973bc/addons/purchase/models/purchase.py#L1055-L1061
By contrast, PO created from the `action_create_alternative`
generate each `purchase.order.line` using `Command.create`. Therefore
these lines will not trigger the onchange method and their taxes
will not be computed.

Fix:

To KISS, we compute the taxes of each line just after the creation of
the record using the `_compute_tax_id` method.

opw-3750719

closes odoo/odoo#158300

X-original-commit: 15799594bda41bdb4b65387aa5f0d46482cb91c1
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2024-03-20 18:29:28 +00:00
..
…