Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
11 Odpowiedzi
10997 Widoki

Hello Team im trying to create a product but by xml file, i know its possible but its giving me the next error : 


odoo.tools.convert.ParseError: "null value in column "purchase_line_warn" violates not-null constraint

DETAIL:  Failing row contains (88, Valencia Product, 1, null, null, null, service, f, 1, 1.00, null, null, t, t, 1, 1, 1, t, null, null, null, null, 1, 2019-01-17 10:52:47.369262, 1, 2019-01-17 10:52:47.369262, manual, no-message, null, no, order, 1, 0, none, null, null, null, null, null, null, null, null, null).

My code is the following:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record
model="product.product" id="hotels_be_bago.product1">
<field
name="name">Valencia Product</field>
<field
name="type">service</field>
<field
name="purchase_line_warn">1</field>
<field
name="sale_line_warn">no-message</field>
</record>

</data>
</odoo>
Why is telling me that is null when i have value 1 set on it?

Thanks for the help    
Awatar
Odrzuć
Najlepsza odpowiedź

I solved this error by putting 'depends': ['sale'], in manifest file

Awatar
Odrzuć

Thanks that works

Najlepsza odpowiedź

Hi,

The error message says that the field named "purchase_line_warn" is not getting the value and it is a required field, so it is mandatory to supply the value for that field.
Checking your data file, it seems you have given 1 for the field purchase_line_warn . The value that can be accepted by this field are 'no-message' ,  'warning' or 'block'



Sample,

<odoo>
<data noupdate="1">
<record model="product.product" id="hotels_be_bago.product1">
<field name="name">Valencia Product</field>
<field name="type">service</field>
<field name="purchase_line_warn">warning</field>
<field name="sale_line_warn">no-message</field>
</record>

</data>
</odoo>

So update the code accordingly and try. Once everything is okay, give noupdate="1" for the data file.


Thanks

Awatar
Odrzuć
Autor

odoo.tools.convert.ParseError: "null value in column "purchase_line_warn" violates not-null constraint

DETAIL: Failing row contains (96, Valencia Product, 1, null, null, null, service, f, 1, 1.00, null, null, t, t, 1, 1, 1, t, null, null, null, null, 1, 2019-01-17 11:10:42.859666, 1, 2019-01-17 11:10:42.859666, manual, no-message, null, no, order, 1, 0, none, null, null, null, null, null, null, null, null, null).

" while parsing /var/lib/odoo/modules/hotels_be_bago/demo/demoProducto.xml:4, near

<record model="product.product" id="hotels_be_bago.product1">

<field name="name">Valencia Product</field>

<field name="type">service</field>

<field name="purchase_line_warn">warning</field>

<field name="sale_line_warn">no-message</field>

</record>

Can you check the same in new db also change the id of the record to 'custom_pro1' and see

Autor

Keeps saying the same even i changed the db and the id

odoo.tools.convert.ParseError: "null value in column "purchase_line_warn" violates not-null constraint

DETAIL: Failing row contains (102, Valencia Product, 1, null, null, null, service, f, 1, 1.00, null, null, t, t, 1, 1, 1, t, null, null, null, null, 1, 2019-01-17 12:10:23.841209, 1, 2019-01-17 12:10:23.841209, manual, no-message, null, no, order, 1, 0, none, null, null, null, null, null, null, null, null, null).

" while parsing /var/lib/odoo/modules/hotels_be_bago/demo/demoProducto.xml:4, near

<record model="product.product" id="custom_pro1">

<field name="name">Valencia Product</field>

<field name="type">service</field>

<field name="purchase_line_warn">warning</field>

<field name="sale_line_warn">no-message</field>

</record>

Have you managed to solve this?

Najlepsza odpowiedź

Hello,

this error message appear if you have already installed your module !

If you uninstalled and installed your module you will not have an error!

Awatar
Odrzuć
Najlepsza odpowiedź

I solved it adding to the _manifest__.py on the "depends" key the purchase module, seems like odoo creates like an "environment" when updating a module and that environment only has whatever the depends key value in the manifest  indicates, so if you have installed the purchase module and then you reinstall a module that creates a new product and you dont have added in the key depends the purchase module, it will not detect all the fields that purchase have added, in this specific case purchase_line_warn, and since the field has a not null constraint the database will raise an exception.

I dont know why odoo developed like this, but not seems to be good. Hope this helps someone who affronts this problem too.


Awatar
Odrzuć
Najlepsza odpowiedź

I'm having the same probem, didn't even have the warning config activated, but seems is a base field, but:

<field name="purchase_line_warn">no-message</field>

doesn't work at all.

Also the field is declared with a default 'no-message' value :

    purchase_line_warn = fields.Selection(WARNING_MESSAGE, 'Purchase Order Line', help=WARNING_HELP, required=True, default="no-message")

Shouldn't take the default value if the field is missed?

Awatar
Odrzuć
Najlepsza odpowiedź

He is right (guy whit kung-fu panda image. Odoo forum is so pathetic that I cannot comment his post or address him in mine)! I had the same issue. If you want to keep updating your module, you have to add noupdate='1' in data tag, but remember that after this everything in this data tag will not be updated while module update.

Awatar
Odrzuć
Autor Najlepsza odpowiedź

It tells me the same...


odoo.tools.convert.ParseError: "null value in column "purchase_line_warn" violates not-null constraint

DETAIL:  Failing row contains (96, Valencia Product, 1, null, null, null, service, f, 1, 1.00, null, null, t, t, 1, 1, 1, t, null, null, null, null, 1, 2019-01-17 11:10:42.859666, 1, 2019-01-17 11:10:42.859666, manual, no-message, null, no, order, 1, 0, none, null, null, null, null, null, null, null, null, null).

" while parsing /var/lib/odoo/modules/hotels_be_bago/demo/demoProducto.xml:4, near

<record model="product.product" id="hotels_be_bago.product1">

<field name="name">Valencia Product</field>

<field name="type">service</field>

<field name="purchase_line_warn">warning</field>

<field name="sale_line_warn">no-message</field>

</record>


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
paź 25
370
2
maj 25
4290
0
lis 24
1359
1
sie 24
2159
1
sie 24
4049