- website_sale_delivery : set the field website_published into a stat button and set the form into a sheet - payment : Payment acquirers unpublished by default, and website_published set into a stat button - website_partner : res_partner unpublished by default, to avoid partners as “Plusbelle LaPoubelle” to be published on the prod (True Story) - website_sale_delivery : Delivery method unpublished by default. Adapt the demo data to be published (to avoid breaking a test), and set the field website_published into a stat button.
47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from openerp.osv import osv, fields
|
|
from openerp.addons.website.models.website import slug
|
|
|
|
|
|
class WebsiteResPartner(osv.Model):
|
|
_name = 'res.partner'
|
|
_inherit = ['res.partner', 'website.seo.metadata', 'website.published.mixin']
|
|
|
|
def _get_ids(self, cr, uid, ids, flds, args, context=None):
|
|
return {i: i for i in ids}
|
|
|
|
def _set_private(self, cr, uid, ids, field_name, value, arg, context=None):
|
|
return self.write(cr, uid, ids, {'website_published': not value}, context=context)
|
|
|
|
def _get_private(self, cr, uid, ids, field_name, arg, context=None):
|
|
return dict((rec.id, not rec.website_published) for rec in self.browse(cr, uid, ids, context=context))
|
|
|
|
def _search_private(self, cr, uid, obj, name, args, context=None):
|
|
return [('website_published', '=', not args[0][2])]
|
|
|
|
_columns = {
|
|
'website_private': fields.function(
|
|
_get_private, fnct_inv=_set_private, fnct_search=_search_private,
|
|
type='boolean', string='Private Profile'),
|
|
'website_description': fields.html(
|
|
'Website Partner Full Description',
|
|
strip_style=True
|
|
),
|
|
'website_short_description': fields.text(
|
|
'Website Partner Short Description'
|
|
),
|
|
# hack to allow using plain browse record in qweb views
|
|
'self': fields.function(_get_ids, type='many2one', relation=_name),
|
|
}
|
|
|
|
def _website_url(self, cr, uid, ids, field_name, arg, context=None):
|
|
res = super(WebsiteResPartner, self)._website_url(cr, uid, ids, field_name, arg, context=context)
|
|
for partner in self.browse(cr, uid, ids, context=context):
|
|
res[partner.id] = "/partners/%s" % slug(partner)
|
|
return res
|
|
|
|
_defaults = {
|
|
'website_private': True,
|
|
}
|