Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
6286 มุมมอง

Hello,

I experimented a case in sale orders and in purchase order. Per example in purchase order, if the RFQ is confirmed as order, when we try to add line we got the following SQL error. The field product_uom containt a non-null constraint and the insert query doesn't feed this field...why?  Same thing in sale order when the quote is confirmed as an order.


Thanks

 odoo.sql_db: bad query: b'INSERT INTO "purchase_order_line" ("id", "order_id", "product_qty", "price_unit", "account_analytic_id", "sequence", "date_planned", "name", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval(\'purchase_order_line_id_seq\'), 338, \'1\', \'0.00\', NULL, 10, \'2018-06-07 00:38:46\', \'QAA-B-01\', 1, 1, (now() at time zone \'UTC\'), (now() at time zone \'UTC\')) RETURNING id'
ERROR: null value in column "product_uom" violates not-null constraint
DETAIL:  Failing row contains (1196, SAV-B-01, 10, 1, 2018-06-07 00:38:46, null, null, 0.00, null, null, null, 338, null, null, null, null, null, null, null, null, 1, 2018-06-07 00:38:56.169986, 1, 2018-06-07 00:38:56.169986)

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Finally, the field is not transfered because there is an attribute on field product_uom: attrs="{'readonly': [('state', 'in', ('purchase', 'done', 'cancel'))]}"

Because the status of pruchase order is "purchase", the field is readonly and not in values during the insert. Why this field is readonly?

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

This is a wild guess but in Odoo any readonly field will not be stored in the database. So what I think happens here is that in your view when you choose a product, the product_uom field is properly set by the onchange event but since it's readonly it will be only visual. In that case you need to make your product_uom field as non-readonly.

It would be nice to see which version of odoo you have to help you more.

อวตาร
ละทิ้ง
ผู้เขียน

Hi, I am using v11 community. I'll take a look about your hint. Thanks

คำตอบที่ดีที่สุด

Hi,

In the error message itself, there is the hint about the issue.  In the sale.order.line and in the purchase.order.line the product_uom field is a required field.


As you haven't supplied the value for the field in your Insert query you are getting the issue. So update the query by providing the product_uom.

Also, check and make sure that no other required fields are missed


Thanks

อวตาร
ละทิ้ง
ผู้เขียน

Hi,

I saw the message, but the product_uom is feeded on the new line at screen. So it's why I don't understand the error message.

Thanks

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 24
5713
0
มี.ค. 15
3395
1
พ.ค. 24
1398
1
มิ.ย. 23
3051
0
มี.ค. 23
2030