Browse Source

[IMP] option to update birthdate from subscription request

pull/11/head
houssine 5 years ago
parent
commit
d10e1d711c
  1. 27
      easy_my_coop/wizard/update_partner_info.py
  2. 6
      easy_my_coop/wizard/update_partner_info.xml

27
easy_my_coop/wizard/update_partner_info.py

@ -17,26 +17,35 @@ class PartnerUpdateInfo(models.TransientModel):
partner = self._get_partner() partner = self._get_partner()
if partner.is_company: if partner.is_company:
return partner.company_register_number return partner.company_register_number
else:
return partner.national_register_number
register_number = fields.Char(string="Register Number", register_number = fields.Char(string="Register 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",
default=_get_partner) default=_get_partner)
all = fields.Boolean(string="Update from subscription request")
birthdate = fields.Boolean(string="set missing birth date")
@api.multi @api.multi
def update(self): def update(self):
partner_obj = self.env['res.partner']
cooperator = self.cooperator cooperator = self.cooperator
coop_vals = {} coop_vals = {}
if cooperator.is_company:
coop_vals['company_register_number'] = self.register_number
if coop_vals:
cooperator.write(coop_vals)
if self.all:
if self.birthdate:
coops = partner_obj.search([('cooperator', '=', True),
('birthdate_date', '=', False),
('is_company', '=', False)])
for coop in coops:
if coop.subscription_request_ids:
sub_req = coop.subscription_request_ids[0]
coop.birthdate_date = sub_req.birthdate
else:
if cooperator:
if cooperator.is_company:
coop_vals['company_register_number'] = self.register_number
if coop_vals:
cooperator.write(coop_vals)
return True return True

6
easy_my_coop/wizard/update_partner_info.xml

@ -10,8 +10,10 @@
Update Cooperator Info. Update Cooperator Info.
</p> </p>
<group> <group>
<field name="all"/>
<field name="birthdate"/>
<field name="cooperator" readonly="True"/> <field name="cooperator" readonly="True"/>
<field name="register_number"/>
<field name="register_number" attrs="{'required':[('all', '=', 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"/>
@ -30,6 +32,6 @@
<field name="target">new</field> <field name="target">new</field>
<field name="groups_id" eval="[(4,ref('easy_my_coop.group_energiris_manager'))]"/> <field name="groups_id" eval="[(4,ref('easy_my_coop.group_energiris_manager'))]"/>
</record> </record>
<menuitem action="action_view_update_partner_info" name="Update coop partner" id="menu_view_update_partner_info" parent="menu_easy_my_coop_main_subscription" sequence="60" groups="base.group_system"/>
</data> </data>
</openerp> </openerp>
Loading…
Cancel
Save