1

From the fleet module I want to delegate a model through the following field:

class FleetVehicle(models.Model):
    _inherit = 'fleet.vehicle'
    
    vehiculo_sat = fields.Many2one(
        comodel_name='l10n_mx_edi.vehicle',
        string="Vehiculo SAT",
        delegate=True,
        default=False,
        store=True,
        required=True
    )

But I don't know how to get both inheritances to keep their own "name" field.

I am having this error:

odoo.sql_db: bad query: INSERT INTO "l10n_mx_edi_vehicle" ("id", "create_uid", "create_date", "write_uid", "write_date", "active", "transport_insurance_policy", "transport_insurer", "transport_perm_sct", "vehicle_config", "vehicle_licence", "vehicle_model") VALUES (nextval('l10n_mx_edi_vehicle_id_seq'), 2, (now() at time zone 'UTC'), 2, (now() at time zone 'UTC'), true, NULL, NULL, NULL, NULL, 'xxx', '2021') RETURNING id ERROR: null value in column "name" of relation "l10n_mx_edi_vehicle" violates not-null constraint

I try to send the "name" field of l10n_mx_edi_vehicle in this way:

    sct_permit_number = fields.Char(string="SCT Permit Number")

    @api.onchange('sct_permit_number', '')
    def change_sat_name(self):
        self.vehiculo_sat.name = self.sct_permit_number

But it still doesn't work. How can i solve this problem?

This can work?

Legna
  • 460
  • 6
  • 19

0 Answers0