Files
odoo_source/addons/website_customer/models/res_partner.py
T
Romain Derie 7a90dedd25 [IMP] website*: use published mixin rather than own field
*website_crm_partner_assign, website_customer

Before this commit, some models would create their own `website_published`
field rather than using the `website.published.mixin` mixin which should be
used instead.

That was done to be able to override the default value of the boolean.

This commit simply adds the possibility to override the default value of the
mixin field.

Also, help and string could simply be added on xml views rather than overriding
the field.
2019-08-03 09:51:22 +00:00

32 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo 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]
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)
def _default_is_published(self):
return True