[FIX] qweb: fix ir.qweb.field.contact
Before this commit when you edit a contact with the editor, you didn't see
the selected record before the save.
Now, you can edit a contact with the html editor.
We move the hacked field self (on res.partner) from website_partner to base.
2 bugs:
field and record was reversed in call
need to pass a browseRecord and not a dict, because we uses .env on it
This hack allow to use widget='contact' on the browse record
itself and not on a specific field from the browse record
Eg:
<div t-field="partner.self" t-options='{
"widget": "contact",
"fields": ["address", "phone"]
}'/>
This commit is contained in:
@@ -10,7 +10,6 @@ Also, adds methods to convert values back to Odoo models.
|
||||
|
||||
import ast
|
||||
import cStringIO
|
||||
import datetime
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
@@ -158,10 +157,12 @@ class Contact(models.AbstractModel):
|
||||
# helper to call the rendering of contact field
|
||||
@api.model
|
||||
def get_record_to_html(self, ids, options=None):
|
||||
node = self.record_to_html('record', {
|
||||
'record': self.env['res.partner'].browse(ids[0])},
|
||||
options=options)
|
||||
return node and node.__html__()
|
||||
node = self.record_to_html(
|
||||
self.env['res.partner'].browse(ids[0]),
|
||||
'self',
|
||||
options=options,
|
||||
)
|
||||
return node
|
||||
|
||||
|
||||
class Date(models.AbstractModel):
|
||||
|
||||
@@ -10,12 +10,6 @@ class WebsiteResPartner(models.Model):
|
||||
|
||||
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.Many2one(comodel_name=_name, compute='_compute_get_ids')
|
||||
|
||||
@api.one
|
||||
def _compute_get_ids(self):
|
||||
self.self = self.id
|
||||
|
||||
@api.multi
|
||||
def _compute_website_url(self):
|
||||
|
||||
@@ -220,6 +220,8 @@ class Partner(models.Model, FormatAddress):
|
||||
help="Small-sized image of this contact. It is automatically "\
|
||||
"resized as a 64x64px image, with aspect ratio preserved. "\
|
||||
"Use this field anywhere a small image is required.")
|
||||
# hack to allow using plain browse record in qweb views, and used in ir.qweb.field.contact
|
||||
self = fields.Many2one(comodel_name=_name, compute='_compute_get_ids')
|
||||
|
||||
_sql_constraints = [
|
||||
('check_name', "CHECK( (type='contact' AND name IS NOT NULL) or (type!='contact') )", 'Contacts require a name.'),
|
||||
@@ -242,6 +244,10 @@ class Partner(models.Model, FormatAddress):
|
||||
for partner in self:
|
||||
partner.contact_address = partner._display_address()
|
||||
|
||||
@api.one
|
||||
def _compute_get_ids(self):
|
||||
self.self = self.id
|
||||
|
||||
@api.depends('is_company', 'parent_id.commercial_partner_id')
|
||||
def _compute_commercial_partner(self):
|
||||
for partner in self:
|
||||
|
||||
Reference in New Issue
Block a user