Browse Source

[IMP] add a field source for the subscription request to track the

source of the creation
pull/1/head
houssine 7 years ago
parent
commit
dac73d0a31
  1. 2
      easy_my_coop/controllers/main.py
  2. 4
      easy_my_coop/models/coop.py
  3. 5
      easy_my_coop/view/subscription_request_view.xml
  4. 16
      easy_my_coop/wizard/create_subscription_from_partner.py

2
easy_my_coop/controllers/main.py

@ -150,11 +150,13 @@ class WebsiteSubscription(http.Controller):
values["lastname"] = lastname
values["firstname"] = firstname
values["birthdate"] = datetime.datetime.strptime(kwargs.get("birthdate"), "%d/%m/%Y").date()
values["source"] = "website"
if kwargs.get("share_product_id"):
product_id = kwargs.get("share_product_id")
product = request.env['product.template'].sudo().browse(int(product_id)).product_variant_ids[0]
values["share_product_id"] = product.id
#check the subscription's amount
company = request.website.company_id
max_amount = company.subscription_maximum_amount

4
easy_my_coop/models/coop.py

@ -156,7 +156,9 @@ class subscription_request(models.Model):
operation_request_id = fields.Many2one('operation.request', string="Operation Request")
is_operation = fields.Boolean(string="Is Operation request")
capital_release_request = fields.One2many('account.invoice','subscription_request', string='Subscription request')
source = fields.Selection([('website','Website'),
('crm','CRM'),
('manual','Manual')], string="Source", default="website")
_order = "id desc"
def _prepare_invoice_line(self, product, partner, qty):

5
easy_my_coop/view/subscription_request_view.xml

@ -63,6 +63,7 @@
</group>
<group>
<field name="date"/>
<field name="source"/>
<field name="activities_address" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="activities_zip_code" attrs="{'invisible':[('is_company','=',False)]}"/>
<field name="activities_city" attrs="{'invisible':[('is_company','=',False)]}"/>
@ -110,6 +111,7 @@
<field name="res_model">subscription.request</field>
<field name="view_type">form</field>
<field name="domain">[('is_company','=',False),('is_operation','=',False)]</field>
<field name="context">{'default_source':'manual'}</field>
<field name="view_id" ref="subscription_request_tree"/>
<field name="search_view_id" ref="view_subscription_request_filter"/>
</record>
@ -131,6 +133,7 @@
<field name="email"/>
<field name="iban"/>
<field name="partner_id"/>
<field name="source"/>
<field name="state"/>
<field name="validated" invisible="True"/>
<button type="object" name="validate_subscription_request" attrs="{'invisible':['|',('state','!=','draft'),('validated','=',False)]}" icon="STOCK_MEDIA_PLAY"/>
@ -145,7 +148,7 @@
<field name="res_model">subscription.request</field>
<field name="view_type">form</field>
<field name="domain">[('is_company','=',True),('is_operation','=',False)]</field>
<field name="context">{'default_is_company': True}</field>
<field name="context">{'default_is_company': True,'default_source':'manual'}</field>
<field name="view_id" ref="company_subscription_request_tree"/>
<field name="search_view_id" ref="view_subscription_request_filter"/>
</record>

16
easy_my_coop/wizard/create_subscription_from_partner.py

@ -79,7 +79,9 @@ class PartnerCreateSubscription(models.TransientModel):
'name': cooperator.name,
'share_product_id':self.share_product.id,
'ordered_parts':self.share_qty,
'user_id':self.env.uid}
'user_id':self.env.uid,
'source':'crm'}
if self.is_company:
vals['company_register_number'] = self.register_number
vals['is_company'] = True
@ -95,6 +97,14 @@ class PartnerCreateSubscription(models.TransientModel):
else:
raise UserError(_("The national register number is not valid."))
sub_req.create(vals)
return {'type': 'ir.actions.act_window_close'}
new_sub_req = sub_req.create(vals)
#return {'type': 'ir.actions.act_window_close'}
return {
'type': 'ir.actions.act_window',
'view_type': 'form, tree',
'view_mode': 'form',
'res_model': 'subscription.request',
'res_id': new_sub_req.id,
'target': 'current',
}
Loading…
Cancel
Save