[16.0][FIX] purchase_manual_delivery: manual delivery with double validation
When "Purchase Order Approval" is enabled and the PO exceeds the Minimum Amount, the manual delivery is not applied at the moment that the PO is approved. This PR fixes this case.
@astirpe Due to a conflict with a merge just now of another PR, your new test in this PR needs to be moved down a little bit.
Picked in my 17.0 migration https://github.com/OCA/purchase-workflow/pull/2417
Unfortunately an access error now appears in your test
2024-09-26T15:37:13.8391675Z 2024-09-26 15:37:13,838 484 [1;32m[1;49mINFO[0m odoo odoo.addons.purchase_manual_delivery.tests.test_purchase_manual_delivery: Starting TestPurchaseManualDelivery.test_05_purchase_order_manual_delivery_double_validation ...
2024-09-26T15:37:14.4727391Z 2024-09-26 15:37:14,472 484 [1;32m[1;49mINFO[0m odoo odoo.addons.base.models.ir_rule: Access Denied by record rules for operation: read on record ids: [170], uid: 14, model: purchase.order.line
2024-09-26T15:37:14.4751428Z 2024-09-26 15:37:14,474 484 [1;32m[1;49mINFO[0m odoo odoo.addons.base.models.ir_rule: Access Denied by record rules for operation: read on record ids: [170], uid: 14, model: purchase.order.line
2024-09-26T15:37:14.4775407Z 2024-09-26 15:37:14,477 484 [1;32m[1;49mINFO[0m odoo odoo.addons.purchase_manual_delivery.tests.test_purchase_manual_delivery: ======================================================================
2024-09-26T15:37:14.4778708Z 2024-09-26 15:37:14,477 484 [1;31m[1;49mERROR[0m odoo odoo.addons.purchase_manual_delivery.tests.test_purchase_manual_delivery: ERROR: TestPurchaseManualDelivery.test_05_purchase_order_manual_delivery_double_validation
2024-09-26T15:37:14.4780741Z Traceback (most recent call last):
2024-09-26T15:37:14.4781131Z File "/opt/odoo/odoo/api.py", line 997, in get
2024-09-26T15:37:14.4781545Z cache_value = field_cache[record._ids[0]]
2024-09-26T15:37:14.4781888Z KeyError: 170
2024-09-26T15:37:14.4782037Z
2024-09-26T15:37:14.4782275Z During handling of the above exception, another exception occurred:
2024-09-26T15:37:14.4782651Z
2024-09-26T15:37:14.4782777Z Traceback (most recent call last):
2024-09-26T15:37:14.4783169Z File "/opt/odoo/odoo/fields.py", line 1161, in __get__
2024-09-26T15:37:14.4783586Z value = env.cache.get(record, self)
2024-09-26T15:37:14.4784182Z File "/opt/odoo/odoo/api.py", line 1004, in get
2024-09-26T15:37:14.4784542Z raise CacheMiss(record, field)
2024-09-26T15:37:14.4785075Z odoo.exceptions.CacheMiss: 'purchase.order.line(170,).company_id'
2024-09-26T15:37:14.4785430Z
2024-09-26T15:37:14.4785660Z During handling of the above exception, another exception occurred:
2024-09-26T15:37:14.4786012Z
2024-09-26T15:37:14.4786125Z Traceback (most recent call last):
2024-09-26T15:37:14.4786494Z File "/opt/odoo/odoo/fields.py", line 1187, in __get__
2024-09-26T15:37:14.4786881Z recs._fetch_field(self)
2024-09-26T15:37:14.4787255Z File "/opt/odoo/odoo/models.py", line 3209, in _fetch_field
2024-09-26T15:37:14.4787652Z self._read(fnames)
2024-09-26T15:37:14.4788060Z File "/opt/odoo/odoo/models.py", line 3335, in _read
2024-09-26T15:37:14.4788629Z raise self.env['ir.rule']._make_access_error('read', forbidden)
2024-09-26T15:37:14.4789625Z odoo.exceptions.AccessError: Due to security restrictions, you are not allowed to access 'Purchase Order Line' (purchase.order.line) records.
2024-09-26T15:37:14.4790316Z
2024-09-26T15:37:14.4790506Z Contact your administrator to request access if necessary.
2024-09-26T15:37:14.4790826Z
2024-09-26T15:37:14.4791056Z During handling of the above exception, another exception occurred:
2024-09-26T15:37:14.4791413Z
2024-09-26T15:37:14.4791527Z Traceback (most recent call last):
2024-09-26T15:37:14.4792553Z File "/__w/purchase-workflow/purchase-workflow/purchase_manual_delivery/tests/test_purchase_manual_delivery.py", line 347, in test_05_purchase_order_manual_delivery_double_validation
2024-09-26T15:37:14.4793460Z .create(po_vals)
@StefanRijnhart Yes, I noticed. I will fix it as soon as I have some time. Thank you!
@StefanRijnhart It seems to me that the access error of the test is caused by the definition of last_purchase_line_ids field in module purchase_last_price_info, in particular is caused by this domain:
https://github.com/OCA/purchase-workflow/blob/16.0/purchase_last_price_info/models/product_product.py#L16-L17
Not sure how to fix it.
/ocabot merge patch
This PR looks fantastic, let's merge it! Prepared branch 16.0-ocabot-merge-pr-2189-by-HviorForgeFlow-bump-patch, awaiting test results.
@HviorForgeFlow your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-2189-by-HviorForgeFlow-bump-patch.
After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.
/ocabot merge patch
What a great day to merge this nice PR. Let's do it! Prepared branch 16.0-ocabot-merge-pr-2189-by-HviorForgeFlow-bump-patch, awaiting test results.
@HviorForgeFlow your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-2189-by-HviorForgeFlow-bump-patch.
After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.
@astirpe can you apply a rebase? Thanks!
It is weird but the fix is adding the company at purchase order line level...
@HviorForgeFlow rebased, thanks!
/ocabot merge patch
This PR looks fantastic, let's merge it! Prepared branch 16.0-ocabot-merge-pr-2189-by-HviorForgeFlow-bump-patch, awaiting test results.
Congratulations, your PR was merged at 39a8d85a5d21830536c70253ef0f26b4d4755e78. Thanks a lot for contributing to OCA. ❤️