[MERGE] forward port of branch 8.0 up to ed1c173
[odoo/odoo.git] / addons / website_partner / models / res_partner.py
1 # -*- coding: utf-8 -*-
2
3 from openerp.osv import osv, fields
4
5
6 class WebsiteResPartner(osv.Model):
7     _name = 'res.partner'
8     _inherit = ['res.partner', 'website.seo.metadata']
9
10     def _get_ids(self, cr, uid, ids, flds, args, context=None):
11         return {i: i for i in ids}
12
13     def _set_private(self, cr, uid, ids, field_name, value, arg, context=None):
14         return self.write(cr, uid, ids, {'website_published': not value}, context=context)
15
16     def _get_private(self, cr, uid, ids, field_name, arg, context=None):
17         return dict((rec.id, not rec.website_published) for rec in self.browse(cr, uid, ids, context=context))
18
19     def _search_private(self, cr, uid, obj, name, args, context=None):
20         return [('website_published', '=', not args[0][2])]
21
22     _columns = {
23         'website_published': fields.boolean(
24             'Publish', help="Publish on the website", copy=False),
25         'website_private': fields.function(
26             _get_private, fnct_inv=_set_private, fnct_search=_search_private,
27             type='boolean', string='Private Profile'),
28         'website_description': fields.html(
29             'Website Partner Full Description'
30         ),
31         'website_short_description': fields.text(
32             'Website Partner Short Description'
33         ),
34         # hack to allow using plain browse record in qweb views
35         'self': fields.function(_get_ids, type='many2one', relation=_name),
36     }
37
38     _defaults = {
39         'website_published': True
40     }