diff --git a/ffck_commons/i18n/fr.po b/ffck_commons/i18n/fr.po
index a8c80ca..75c782f 100644
--- a/ffck_commons/i18n/fr.po
+++ b/ffck_commons/i18n/fr.po
@@ -92,6 +92,12 @@ msgstr ""
msgid "FFCK code"
msgstr "Code FFCK"
+#. module: ffck_commons
+#: model:ir.model.fields,field_description:ffck_commons.field_res_users__local_partner_code_editable
+#: model:ir.model.fields,field_description:ffck_commons.field_res_users__partner_code_editable
+msgid "FFCK code editable"
+msgstr "Code FFCK éditable"
+
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__ffck_network
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__ffck_network
diff --git a/ffck_commons/models/res_partner.py b/ffck_commons/models/res_partner.py
index 5d8dc84..f4ae7f1 100644
--- a/ffck_commons/models/res_partner.py
+++ b/ffck_commons/models/res_partner.py
@@ -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)
diff --git a/ffck_commons/views/res_partner.xml b/ffck_commons/views/res_partner.xml
index ae3bcac..dab701e 100644
--- a/ffck_commons/views/res_partner.xml
+++ b/ffck_commons/views/res_partner.xml
@@ -22,10 +22,10 @@
attrs="{'invisible': [('is_company','=',True)]}" />
-
+
+
-