[FIX] stock_orderpoint_origin: Empty procurement - #88
Open
SirPyTech wants to merge 1 commit into
Open
Conversation
If there is no procurement in a source document, the following is raised:
ERROR devel odoo.sql_db: bad query: INSERT INTO procurement_group_purchase_order_line_rel (purchase_order_line_id, procurement_group_id) VALUES (24, 5), (24, false) ON CONFLICT DO NOTHING
ERROR: column "procurement_group_id" is of type integer but expression is of type boolean
LINE 1: ...ne_id, procurement_group_id) VALUES (24, 5), (24, false) ON ...
^
HINT: You will need to rewrite or cast the expression.
ERROR devel odoo.addons.stock_orderpoint_origin.tests.test_stock_orderpoint: ERROR: TestOrderpointPurchaseLink.test_picking_empty_procurement
Traceback (most recent call last):
File "/opt/odoo/auto/addons/stock_orderpoint_origin/tests/test_stock_orderpoint.py", line 78, in test_picking_empty_procurement
op.action_replenish()
File "/opt/odoo/auto/addons/stock/models/stock_orderpoint.py", line 229, in action_replenish
self._procure_orderpoint_confirm(company_id=self.env.company)
File "/opt/odoo/auto/addons/stock/models/stock_orderpoint.py", line 568, in _procure_orderpoint_confirm
self.env['procurement.group'].with_context(from_orderpoint=True).run(procurements, raise_user_error=raise_user_error)
File "/opt/odoo/auto/addons/stock_orderpoint_origin/models/procurement_group.py", line 43, in run
return super().run(new_procurements, raise_user_error)
File "/opt/odoo/auto/addons/purchase_stock/models/stock.py", line 247, in run
return super().run(procurements, raise_user_error=raise_user_error)
File "/opt/odoo/auto/addons/stock/models/stock_rule.py", line 479, in run
getattr(self.env['stock.rule'], '_run_%s' % action)(procurements)
File "/opt/odoo/auto/addons/purchase_stock/models/stock_rule.py", line 157, in _run_buy
self.env['purchase.order.line'].sudo().create(po_line_values)
File "<decorator-gen-216>", line 2, in create
File "/opt/odoo/custom/src/odoo/odoo/api.py", line 431, in _model_create_multi
return create(self, arg)
File "/opt/odoo/auto/addons/purchase_stock/models/purchase.py", line 392, in create
lines = super(PurchaseOrderLine, self).create(vals_list)
File "<decorator-gen-213>", line 2, in create
File "/opt/odoo/custom/src/odoo/odoo/api.py", line 431, in _model_create_multi
return create(self, arg)
File "/opt/odoo/auto/addons/purchase/models/purchase.py", line 1130, in create
lines = super().create(vals_list)
File "<decorator-gen-160>", line 2, in create
File "/opt/odoo/custom/src/odoo/odoo/api.py", line 431, in _model_create_multi
return create(self, arg)
File "/opt/odoo/auto/addons/analytic/models/analytic_mixin.py", line 89, in create
return super().create(vals_list)
File "<decorator-gen-68>", line 2, in create
File "/opt/odoo/custom/src/odoo/odoo/api.py", line 431, in _model_create_multi
return create(self, arg)
File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_fields.py", line 670, in create
recs = super().create(vals_list)
File "<decorator-gen-15>", line 2, in create
File "/opt/odoo/custom/src/odoo/odoo/api.py", line 431, in _model_create_multi
return create(self, arg)
File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4019, in create
records = self._create(data_list)
File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4256, in _create
field.create([
File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 4287, in create
self.write_batch(record_values, True)
File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 4313, in write_batch
return self.write_real(records_commands_list, create)
File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 4910, in write_real
cr.execute(query, pairs)
File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 324, in execute
res = self._obj.execute(query, params)
psycopg2.errors.DatatypeMismatch: column "procurement_group_id" is of type integer but expression is of type boolean LINE 1: ...ne_id, procurement_group_id) VALUES (24, 5), (24, false) ON ...
^
HINT: You will need to rewrite or cast the expression.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If there is no procurement in a source document, the following is raised:
I also change the
source_group_idsvalue so that it's a recordset, like the other*_idsvalues inprocurement.values(see for instance https://github.com/odoo/odoo/blob/6aca71c9522b3be5b221847e8b005f233d3ea872/addons/purchase_stock/models/stock.py#L246) because the error was actually triggered instock-logistics-orderpoint/stock_orderpoint_origin/models/purchase_order.py
Lines 36 to 38 in eebb6d3
groupsis[procurement.group()], so a[(4, False)]is added, and then the above error is triggered when converting that to a query.