跳至内容
菜单
此问题已终结
3 回复
7114 查看

I got this error when i click on "Run Procurement"  button in the module "Inventory" or when I click 'Confirm Sale' in module 'Sale'.

Odoo Warning - Validation Error

Error while validating constraint

'purchase.order.line' object has no attribute 'purchase_id'   

Note that the route of  the product listed in the sales order has been set to 'Buy' and 'Make to Order'.  Also I  created a reordering rule for this product. I I wanted is to trigger a purchase order whenever the stock  reaches the minimum level.  I am using odoo version 9.0c-20170906

形象
丢弃
最佳答案

Hi,

You can check whether you are getting this issue in odoo runbot or not. You can access it from the following link :  http://runbot.odoo.com/runbot

Choose V9 and log in using the credentials email: admin and password: admin

If you are not able to reproduce the issue in the runbot please update your version to the latest of odoo v9.


Most probably you will not get such an error in runbot, if you found means you can report it at : https://github.com/odoo/odoo/issues

 Thanks

形象
丢弃
编写者 最佳答案

Samo Arko, reordering rule is from the feature of inventory module. Anyway, i traced the code that triggers creation of purchase order, the error raised at line 983 in purchase.py of purchase module. Ill try in runboot if i could recreate the error.

#981            if not po_line:
#982                vals = procurement._prepare_purchase_order_line(po, supplier)
#983                self.env['purchase.order.line'].create(vals)
#984        return res
形象
丢弃

Then you probably try to create it with wrong data.

To see what you're passing you can create a custom module where you inherit the model and override the method (copy/paste) and add raise ValidationError('values {}'.format(vals)) before the code on line 983 and you'll with what data you try to create the record.

编写者

Thanks for the input. I already traced the culprit. It came from the custom module named operating_unit. They put a constraint in purchase _id in the inherited model of procurement.order.

最佳答案

Your reordering rule, is it a custom module? If it is you need to add the module sale to the dependencies of your custom module.

If you have an error in your custom code it can prevent to load the module whole and this can cause the problem.

This two things are normally what causes my modules to raise the validation constrain error.   

形象
丢弃
相关帖文 回复 查看 活动
0
11月 15
5975
1
8月 15
4790
1
3月 24
2108
1
6月 20
5529
0
11月 15
3558