flectra/addons/website_partner/models/res_partner.py
Siddharth Bhalgami e088762a21 [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-12 18:44:52 +05:30

29 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
from flectra import api, fields, models
from flectra.addons.http_routing.models.ir_http import slug
class WebsiteResPartner(models.Model):
_name = 'res.partner'
_inherit = ['res.partner', 'website.seo.metadata', 'website.published.mixin']
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_description = fields.Html('Website Partner Full Description', strip_style=True)
website_short_description = fields.Text('Website Partner Short Description')
website_ids = fields.Many2many('website', 'website_partner_pub_rel',
'website_id', 'partner_id',
string='Websites', copy=False,
default=_default_website,
help='List of websites in which '
'Partner will published.')
@api.multi
def _compute_website_url(self):
super(WebsiteResPartner, self)._compute_website_url()
for partner in self:
partner.website_url = "/partners/%s" % slug(partner)