2018-01-16 06:58:15 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-01-16 11:34:37 +01:00
|
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
2018-01-16 06:58:15 +01:00
|
|
|
|
2018-01-16 11:34:37 +01:00
|
|
|
from flectra import api, fields, models
|
|
|
|
from flectra.addons.http_routing.models.ir_http import slug
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ResPartnerGrade(models.Model):
|
|
|
|
_name = 'res.partner.grade'
|
|
|
|
_inherit = ['website.published.mixin']
|
|
|
|
|
[IMP] Improve Multi-Website Functionalities:-
- Affected Modules:
website_sale, website_blog, website_partner, website_crm_partner_assign,
website_customer, website_slides, website_links, website_membership,
website_hr, website_hr_recruitment, website_payment, website_sale_delivery,
website_forum, website_event
- Remove unnecessary model `website.product.pricelist` from website_sale,
All its mechanism already transferd to existing model `product.pricelist`
- Change in `product.pricelist` model, make website_id(o2m) to website_ids(m2m),
As user can choose that same pricelist can be used in multiple websites
- Added `default_website` as default values in `website_ids(m2m)` & `website_id(m2o)` field in
almost all affected modules (mentioned above!!)
- To use/publish things(like... product, pricelist, blog, forum, events, etc...) in website,
User have to set `website_published` mechanism `on` (if it's available for that model/object),
Also have to set/assign different websites in `website_ids` field as per needs
2018-02-06 10:43:31 +01:00
|
|
|
def _default_website(self):
|
|
|
|
default_website_id = self.env.ref('website.default_website')
|
|
|
|
return [default_website_id.id] if default_website_id else None
|
|
|
|
|
2018-01-16 06:58:15 +01:00
|
|
|
website_published = fields.Boolean(default=True)
|
|
|
|
sequence = fields.Integer('Sequence')
|
|
|
|
active = fields.Boolean('Active', default=lambda *args: 1)
|
|
|
|
name = fields.Char('Level Name', translate=True)
|
|
|
|
partner_weight = fields.Integer('Level Weight', default=1,
|
|
|
|
help="Gives the probability to assign a lead to this partner. (0 means no assignation.)")
|
2017-12-25 06:24:55 +01:00
|
|
|
website_ids = fields.Many2many('website', 'website_partner_grade_pub_rel',
|
|
|
|
'website_id', 'partner_grade_id',
|
|
|
|
string='Websites', copy=False,
|
[IMP] Improve Multi-Website Functionalities:-
- Affected Modules:
website_sale, website_blog, website_partner, website_crm_partner_assign,
website_customer, website_slides, website_links, website_membership,
website_hr, website_hr_recruitment, website_payment, website_sale_delivery,
website_forum, website_event
- Remove unnecessary model `website.product.pricelist` from website_sale,
All its mechanism already transferd to existing model `product.pricelist`
- Change in `product.pricelist` model, make website_id(o2m) to website_ids(m2m),
As user can choose that same pricelist can be used in multiple websites
- Added `default_website` as default values in `website_ids(m2m)` & `website_id(m2o)` field in
almost all affected modules (mentioned above!!)
- To use/publish things(like... product, pricelist, blog, forum, events, etc...) in website,
User have to set `website_published` mechanism `on` (if it's available for that model/object),
Also have to set/assign different websites in `website_ids` field as per needs
2018-02-06 10:43:31 +01:00
|
|
|
default=_default_website,
|
2017-12-25 06:24:55 +01:00
|
|
|
help='List of websites in which '
|
[IMP] Improve Multi-Website Functionalities:-
- Affected Modules:
website_sale, website_blog, website_partner, website_crm_partner_assign,
website_customer, website_slides, website_links, website_membership,
website_hr, website_hr_recruitment, website_payment, website_sale_delivery,
website_forum, website_event
- Remove unnecessary model `website.product.pricelist` from website_sale,
All its mechanism already transferd to existing model `product.pricelist`
- Change in `product.pricelist` model, make website_id(o2m) to website_ids(m2m),
As user can choose that same pricelist can be used in multiple websites
- Added `default_website` as default values in `website_ids(m2m)` & `website_id(m2o)` field in
almost all affected modules (mentioned above!!)
- To use/publish things(like... product, pricelist, blog, forum, events, etc...) in website,
User have to set `website_published` mechanism `on` (if it's available for that model/object),
Also have to set/assign different websites in `website_ids` field as per needs
2018-02-06 10:43:31 +01:00
|
|
|
'Partner Grade will published.')
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
@api.multi
|
|
|
|
def _compute_website_url(self):
|
|
|
|
super(ResPartnerGrade, self)._compute_website_url()
|
|
|
|
for grade in self:
|
|
|
|
grade.website_url = "/partners/grade/%s" % (slug(grade))
|
|
|
|
|
|
|
|
|
|
|
|
class ResPartnerActivation(models.Model):
|
|
|
|
_name = 'res.partner.activation'
|
|
|
|
_order = 'sequence'
|
|
|
|
|
|
|
|
sequence = fields.Integer('Sequence')
|
|
|
|
name = fields.Char('Name', required=True)
|
|
|
|
|
|
|
|
|
|
|
|
class ResPartner(models.Model):
|
|
|
|
_inherit = "res.partner"
|
|
|
|
|
|
|
|
partner_weight = fields.Integer('Level Weight', default=lambda *args: 0,
|
|
|
|
help="Gives the probability to assign a lead to this partner. (0 means no assignation.)")
|
|
|
|
grade_id = fields.Many2one('res.partner.grade', 'Level')
|
|
|
|
grade_sequence = fields.Integer(related='grade_id.sequence', readonly=True, store=True)
|
|
|
|
activation = fields.Many2one('res.partner.activation', 'Activation', index=True)
|
|
|
|
date_partnership = fields.Date('Partnership Date')
|
|
|
|
date_review = fields.Date('Latest Partner Review')
|
|
|
|
date_review_next = fields.Date('Next Partner Review')
|
|
|
|
# customer implementation
|
|
|
|
assigned_partner_id = fields.Many2one(
|
|
|
|
'res.partner', 'Implemented by',
|
|
|
|
)
|
|
|
|
implemented_partner_ids = fields.One2many(
|
|
|
|
'res.partner', 'assigned_partner_id',
|
|
|
|
string='Implementation References',
|
|
|
|
)
|
|
|
|
implemented_count = fields.Integer(compute='_compute_implemented_partner_count', store=True)
|
|
|
|
|
|
|
|
@api.one
|
|
|
|
@api.depends('implemented_partner_ids', 'implemented_partner_ids.website_published', 'implemented_partner_ids.active')
|
|
|
|
def _compute_implemented_partner_count(self):
|
|
|
|
self.implemented_count = len(self.implemented_partner_ids.filtered('website_published'))
|
|
|
|
|
|
|
|
@api.onchange('grade_id')
|
|
|
|
def _onchange_grade_id(self):
|
|
|
|
grade = self.grade_id
|
|
|
|
self.partner_weight = grade.partner_weight if grade else 0
|