fix partner
This commit is contained in:
parent
13e7aef41f
commit
c6faff5cb9
|
|
@ -1572,4 +1572,31 @@ msgstr "المرشحين"
|
|||
#. module: dev_membership
|
||||
#: model:ir.actions.report,name:dev_membership.menu_print_membership_nomination
|
||||
msgid "Print Membership Nomination"
|
||||
msgstr "طباعة المرشحين للعضوية"
|
||||
msgstr "طباعة المرشحين للعضوية"
|
||||
|
||||
|
||||
|
||||
|
||||
#. module: dev_membership
|
||||
#: code:addons/dev_membership/models/res_partner.py:0
|
||||
#, python-format
|
||||
msgid "Mobile number must be exactly 10 digits."
|
||||
msgstr "يجب أن يتكون رقم الجوال من 10 أرقام بالضبط."
|
||||
|
||||
|
||||
#. module: dev_membership
|
||||
#: code:addons/dev_membership/models/res_partner.py:0
|
||||
#, python-format
|
||||
msgid "ID number must be unique."
|
||||
msgstr "يجب أن يكون رقم الهوية فريدًا."
|
||||
|
||||
#. module: dev_membership
|
||||
#: code:addons/dev_membership/models/res_partner.py:0
|
||||
#, python-format
|
||||
msgid "Mobile number is required for members."
|
||||
msgstr "رقم الجوال مطلوب للأعضاء."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -166,52 +166,56 @@ class Partner(models.Model):
|
|||
'target': 'current',
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@api.constrains('identification_number', 'is_member')
|
||||
def _check_id_no_required_if_member(self):
|
||||
for record in self:
|
||||
if record.is_member and not record.identification_number:
|
||||
raise ValidationError(_("ID number is required for members."))
|
||||
|
||||
@api.constrains('mobile', 'is_member')
|
||||
def _check_mobile_required_if_member(self):
|
||||
for record in self:
|
||||
if record.is_member and not record.mobile:
|
||||
raise ValidationError(_("Mobile number is required for members."))
|
||||
|
||||
@api.constrains('mobile', 'identification_number')
|
||||
def _check_unique_mobile_id(self):
|
||||
for record in self:
|
||||
if record.mobile:
|
||||
existing_mobile = self.search([
|
||||
('mobile', '=', record.mobile),
|
||||
('id', '!=', record.id)
|
||||
], limit=1)
|
||||
if existing_mobile:
|
||||
raise ValidationError(_("Mobile number must be unique."))
|
||||
if record.identification_number:
|
||||
existing_id = self.search([
|
||||
('identification_number', '=', record.identification_number),
|
||||
('id', '!=', record.id)
|
||||
], limit=1)
|
||||
if existing_id:
|
||||
raise ValidationError(_("ID number must be unique."))
|
||||
|
||||
@api.constrains('mobile')
|
||||
@api.onchange('mobile')
|
||||
def _check_mobile_format(self):
|
||||
print("Test constraint running!")
|
||||
for record in self:
|
||||
print("Checking mobile format: %s", record.mobile)
|
||||
if record.mobile and (len(record.mobile) != 10 or not record.mobile.isdigit()):
|
||||
raise ValidationError(_("Mobile number must be exactly 10 digits."))
|
||||
if record.mobile and not (len(record.mobile) == 10 and record.mobile.isdigit()):
|
||||
raise ValidationError("Mobile number must be exactly 10 digits.")
|
||||
|
||||
|
||||
# Optional: Add SQL constraints for uniqueness
|
||||
_sql_constraints = [
|
||||
('unique_mobile', 'UNIQUE(mobile)', 'Mobile number must be unique.'),
|
||||
('unique_identification_number', 'UNIQUE(identification_number)', 'ID number must be unique.'),
|
||||
]
|
||||
|
||||
|
||||
# @api.constrains('identification_number')
|
||||
# def _check_id_no_required_if_member(self):
|
||||
# for record in self:
|
||||
# if record.is_member and not record.identification_number:
|
||||
# raise ValidationError(_("ID number is required for members."))
|
||||
|
||||
@api.constrains('mobile','is_member')
|
||||
def _check_mobile_required_if_member(self):
|
||||
for record in self:
|
||||
if record.is_member and not record.mobile:
|
||||
raise ValidationError(_("Mobile number is required for members."))
|
||||
|
||||
@api.constrains('identification_number')
|
||||
def _check_unique_mobile_id(self):
|
||||
for record in self:
|
||||
# if record.mobile:
|
||||
# existing_mobile = self.search([
|
||||
# ('mobile', '=', record.mobile),
|
||||
# ('id', '!=', record.id)
|
||||
# ], limit=1)
|
||||
# if existing_mobile :
|
||||
# raise ValidationError(_("Mobile number must be unique."))
|
||||
if record.identification_number:
|
||||
existing_id = self.search([
|
||||
('identification_number', '=', record.identification_number),
|
||||
('id', '!=', record.id)
|
||||
], limit=1)
|
||||
if existing_id:
|
||||
raise ValidationError(_("ID number must be unique."))
|
||||
|
||||
# @api.constrains('mobile')
|
||||
# def _check_mobile_format(self):
|
||||
|
||||
# for record in self:
|
||||
# print("Checking mobile format: %s", record.mobile)
|
||||
# if record.mobile and (len(record.mobile) != 10 or not record.mobile.isdigit()) and not record.user_ids:
|
||||
# raise ValidationError(_("Mobile number must be exactly 10 digits."))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,5 @@
|
|||
<field name="domain_force">[(1,'=',1)]</field>
|
||||
<field name="groups" eval="[(4, ref('group_membership_manager'))]"/>
|
||||
</record>
|
||||
<record id="sale_purchase_tab" model="res.groups">
|
||||
<field name="name">Sale/Purchase Tab</field>
|
||||
<field name="category_id" ref="dev_membership.membership_category"/> <!-- Or use your own category -->
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
|
|
|||
|
|
@ -170,12 +170,22 @@
|
|||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='sales_purchases']" position="attributes">
|
||||
<attribute name="groups">dev_membership.sale_purchase_tab</attribute>
|
||||
</xpath>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<xpath expr="//field[@name='title']" position="replace"></xpath>
|
||||
|
||||
<xpath expr="//sheet/group/group[2]/field[@name='mobile']" position="before">
|
||||
<field name="is_member" />
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//sheet/group/group[2]/field[@name='mobile']" position="attributes">
|
||||
<attribute name="attrs">{'required': [('is_member', '=', True)]}</attribute>
|
||||
<attribute name="options">{"pattern": "[0-9]{10}"}</attribute>
|
||||
|
||||
</xpath>
|
||||
|
||||
|
||||
|
||||
<xpath expr="//div/h1" position="replace">
|
||||
<h1 class="o_addressformat">
|
||||
|
|
@ -272,6 +282,9 @@
|
|||
<field name="age"/>
|
||||
</group>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='identification_number']" position="attributes">
|
||||
<attribute name="attrs">{'required': [('is_member', '=', True)]}</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue