flectra/addons/website_customer/models/res_partner.py

40 lines
1.7 KiB
Python
Raw Normal View History

# -*- 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 11:34:37 +01:00
from flectra import api, fields, models
class Partner(models.Model):
_inherit = 'res.partner'
website_tag_ids = fields.Many2many('res.partner.tag', 'res_partner_res_partner_tag_rel', 'partner_id', 'tag_id', string='Website tags')
class Tags(models.Model):
_name = 'res.partner.tag'
_description = 'Partner Tags - These tags can be used on website to find customers by sector, or ... '
_inherit = 'website.published.mixin'
@api.model
def get_selection_class(self):
classname = ['default', 'primary', 'success', 'warning', 'danger']
return [(x, str.title(x)) for x in classname]
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
name = fields.Char('Category Name', required=True, translate=True)
partner_ids = fields.Many2many('res.partner', 'res_partner_res_partner_tag_rel', 'tag_id', 'partner_id', string='Partners')
classname = fields.Selection(get_selection_class, 'Class', default='default', help="Bootstrap class to customize the color", required=True)
active = fields.Boolean('Active', default=True)
website_published = fields.Boolean(default=True)
website_ids = fields.Many2many('website', 'website_partner_tag_pub_rel',
'website_id', 'partner_tag_id',
string='Websites', copy=False,
default=_default_website,
help='List of websites in which '
'Partner Tag will published.')