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

Hi!


When building a custom module in odoo.sh I get the following error:


AssertionError: nombre is a required field ({'invisible': [('company_type', '=', 'company')], 'required': [('company_type', '=', 'person')]})

The field definition is:

nombre = fields.Char(string="Primer Nombre")

It is a simple field so I don't understand what the error means, could you please help me?


Thank you

Greetings


形象
丢弃

try deleting existing records in the table and see, whether the error is still there

编写者

The error occurs when a build is generated in development, that is, with an empty database that from what I see later, demo data is generated.

编写者

Hello,

Thanks Ray for your reply. Finally leave the field like this:

name = fields.Char (string = "First Name", default = "")

And the error disappeared.

Greetings

最佳答案

It appears you have made your nombre field required for all res.partner records where company_type = person.

The development branches run test suites which include creating res.partner records, but since those test suites don't know anything about your nombre field, they are not providing a value, which causes the error.

If you set a default value for your nombre field, then the Odoo test trying to create a res.partner record won't face the error, because the field will have a value as required.

 

形象
丢弃

Basically, this error should not occur even if a value is not provided.

completely similar as when we setup Odoo locally and there's a required field that is null, the system tells us there's a bad query precising that the required field has null value but most importantly, no error at all failing the run of Odoo.

It happens due to the nature of the testing code that is run during development builds of the branch on Odoo.sh - when you setup Odoo locally there are no such tests run unless you use the `--test-enable` option on the command-line or configuration file.

相关帖文 回复 查看 活动
0
5月 21
2314
2
1月 23
2308
0
5月 22
2262
1
7月 25
2195
2
7月 25
7697