-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Describe the bug
I was looking through some of the error messages we have when running OpenSPP, and I see that some code we have is trying to make guarantees it cannot.
An example is in the spp_farmer_registry_base
, which is extending res_partner
.
In the class Farm
, we have this:
farm_detail_id = fields.Many2one("spp.farm.details", required=True, ondelete="cascade", string="Farm Detail")
farm_land_rec_id = fields.Many2one("spp.land.record", required=True, ondelete="cascade", string="Land Record")
farmer_id = fields.Many2one("spp.farmer", required=True, ondelete="cascade", string="Farmer")
As we use res_partner
for other things, the required=True
cannot be here, as this will issue the SQL statement ALTER TABLE "res_partner" ALTER COLUMN "farm_detail_id" SET NOT NULL
which will fail.
Thus, the source code gives the impression that there are guarantees, where they in fact cannot be met.
To Reproduce
Install the spp_farmer_registry_base
addon.
Expected behavior
No error messages related to the above fields (farm_detail_id
, farm_land_rec_id
and farmer_id
) should be shown in the OpenSPP log or the database log.
Additional context
The OpenSPP log messages:
ERROR farmer_registry odoo.schema: Table 'res_partner': unable to set NOT NULL on column 'farm_detail_id'
ERROR farmer_registry odoo.schema: Table 'res_partner': unable to set NOT NULL on column 'farm_land_rec_id'
ERROR farmer_registry odoo.schema: Table 'res_partner': unable to set NOT NULL on column 'farmer_id'
The database log messages:
ERROR: column "farm_detail_id" of relation "res_partner" contains null values
STATEMENT: ALTER TABLE "res_partner" ALTER COLUMN "farm_detail_id" SET NOT NULL
ERROR: column "farm_land_rec_id" of relation "res_partner" contains null values
STATEMENT: ALTER TABLE "res_partner" ALTER COLUMN "farm_land_rec_id" SET NOT NULL
ERROR: column "farmer_id" of relation "res_partner" contains null values
STATEMENT: ALTER TABLE "res_partner" ALTER COLUMN "farmer_id" SET NOT NULL