|
|
@ -22,7 +22,7 @@ class ResPartner(models.Model): |
|
|
|
string="Structure type", |
|
|
|
) |
|
|
|
partner_code = fields.Char(string="FFCK code", size=6, index=True) |
|
|
|
# partner_code_editable = fields.Boolean(string="FFCK code editable", compute="_can_edit_partner_code") |
|
|
|
partner_code_editable = fields.Boolean(string="FFCK code editable", default=True) |
|
|
|
# FFCK |
|
|
|
ffck_partner_id = fields.Many2one( |
|
|
|
comodel_name="res.partner", |
|
|
@ -175,8 +175,16 @@ class ResPartner(models.Model): |
|
|
|
@api.onchange("partner_code", "company_type", "ffck_network") |
|
|
|
def onchange_partner_code(self): |
|
|
|
if self.ffck_network and self.is_company == False: |
|
|
|
code = self.partner_code |
|
|
|
code = self.partner_code or "000000" |
|
|
|
if len(code) < 6: |
|
|
|
self.update({"partner_code": code.zfill(6)}) |
|
|
|
elif len(code) > 6: |
|
|
|
self.update({"partner_code": code[:-6]}) |
|
|
|
|
|
|
|
# CRUD |
|
|
|
|
|
|
|
@api.model_create_multi |
|
|
|
def create(self, vals_list): |
|
|
|
for vals in vals_list: |
|
|
|
vals.update({"partner_code_editable": False}) |
|
|
|
return super().create(vals_list) |