Browse Source

[IMP] ffck code management

16.0
RemiFr82 6 months ago
parent
commit
4c7b773aad
  1. 6
      ffck_commons/i18n/fr.po
  2. 12
      ffck_commons/models/res_partner.py
  3. 6
      ffck_commons/views/res_partner.xml

6
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

12
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)

6
ffck_commons/views/res_partner.xml

@ -22,10 +22,10 @@
attrs="{'invisible': [('is_company','=',True)]}" />
<label for="partner_code" string="Structure code"
attrs="{'invisible': [('is_company','=',False)]}" />
<field name="partner_code" nolabel="1" readonly="1" />
<field name="partner_code" nolabel="1"
attrs="{'readonly':[('partner_code_editable','=',False)],'required':[('partner_code_editable','=',False)]}" />
<field name="partner_code_editable" invisible="1" />
<!-- <field name="partner_code" groups="base.group_no_one" /> -->
<!-- <field name="partner_code" nolabel="1" attrs="{'readonly':[('partner_code_editable','=',False)]}" />
<field name="partner_code_editable" invisible="1" /> -->
<field name="partner_scale" attrs="{'invisible': [('is_company','=',False)]}" />
<field name="ffck_structure_type_id" widget="selection"
attrs="{'invisible': [('is_company','=',False)]}" />

Loading…
Cancel
Save