Browse Source

[FIX] register number non required when partner is a company

pull/39/head
houssine 5 years ago
parent
commit
392128c41c
  1. 7
      easy_my_coop/wizard/update_partner_info.py
  2. 3
      easy_my_coop/wizard/update_partner_info.xml

7
easy_my_coop/wizard/update_partner_info.py

@ -16,8 +16,13 @@ class PartnerUpdateInfo(models.TransientModel):
if partner.is_company: if partner.is_company:
return partner.company_register_number return partner.company_register_number
@api.model
def _get_is_company(self):
return self._get_partner().is_company
is_company = fields.Boolean(string="Is company",
default=_get_is_company)
register_number = fields.Char(string="Register Company Number", register_number = fields.Char(string="Register Company Number",
required=True,
default=_get_register_number) default=_get_register_number)
cooperator = fields.Many2one('res.partner', cooperator = fields.Many2one('res.partner',
string="Cooperator", string="Cooperator",

3
easy_my_coop/wizard/update_partner_info.xml

@ -10,12 +10,13 @@
Update Cooperator Info. Update Cooperator Info.
</p> </p>
<group> <group>
<field name="is_company" invisible="True"/>
<field name="all"/> <field name="all"/>
<field name="birthdate"/> <field name="birthdate"/>
<field name="legal_form"/> <field name="legal_form"/>
<field name="representative_function"/> <field name="representative_function"/>
<field name="cooperator" readonly="True"/> <field name="cooperator" readonly="True"/>
<field name="register_number" attrs="{'required':[('all', '=', False)]}"/>
<field name="register_number" attrs="{'required':['|', ('is_company', '=', True), ('all', '=', False)], 'invisible':[('is_company', '=', False)]}"/>
</group> </group>
<footer> <footer>
<button name="update" string="Update Info" type="object" class="btn-primary"/> <button name="update" string="Update Info" type="object" class="btn-primary"/>

Loading…
Cancel
Save