purchase-workflow icon indicating copy to clipboard operation
purchase-workflow copied to clipboard

[16.0][FIX] purchase_manual_delivery: manual delivery with double validation

Open astirpe opened this issue 1 year ago • 5 comments

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 avatar Feb 28 '24 12:02 astirpe

@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.

StefanRijnhart avatar Sep 26 '24 08:09 StefanRijnhart

Picked in my 17.0 migration https://github.com/OCA/purchase-workflow/pull/2417

StefanRijnhart avatar Sep 26 '24 14:09 StefanRijnhart

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 avatar Sep 26 '24 18:09 StefanRijnhart

@StefanRijnhart Yes, I noticed. I will fix it as soon as I have some time. Thank you!

astirpe avatar Sep 26 '24 18:09 astirpe

@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.

astirpe avatar Oct 01 '24 11:10 astirpe

/ocabot merge patch

HviorForgeFlow avatar Jan 08 '25 21:01 HviorForgeFlow

This PR looks fantastic, let's merge it! Prepared branch 16.0-ocabot-merge-pr-2189-by-HviorForgeFlow-bump-patch, awaiting test results.

OCA-git-bot avatar Jan 08 '25 21:01 OCA-git-bot

@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.

OCA-git-bot avatar Jan 08 '25 21:01 OCA-git-bot

/ocabot merge patch

HviorForgeFlow avatar Jan 10 '25 14:01 HviorForgeFlow

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.

OCA-git-bot avatar Jan 10 '25 14:01 OCA-git-bot

@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.

OCA-git-bot avatar Jan 10 '25 14:01 OCA-git-bot

@astirpe can you apply a rebase? Thanks!

HviorForgeFlow avatar Jan 10 '25 14:01 HviorForgeFlow

It is weird but the fix is adding the company at purchase order line level...

HviorForgeFlow avatar Jan 10 '25 17:01 HviorForgeFlow

@HviorForgeFlow rebased, thanks!

astirpe avatar Jan 10 '25 17:01 astirpe

/ocabot merge patch

HviorForgeFlow avatar Jan 10 '25 17:01 HviorForgeFlow

This PR looks fantastic, let's merge it! Prepared branch 16.0-ocabot-merge-pr-2189-by-HviorForgeFlow-bump-patch, awaiting test results.

OCA-git-bot avatar Jan 10 '25 17:01 OCA-git-bot

Congratulations, your PR was merged at 39a8d85a5d21830536c70253ef0f26b4d4755e78. Thanks a lot for contributing to OCA. ❤️

OCA-git-bot avatar Jan 10 '25 18:01 OCA-git-bot