Open dreamhunter2333 opened 3 years ago
class A(models.Model):
_name = 'a'
char = fields.Char()
lines = fields.One2many('a.line')
@api.onchange('char'):
def onchange_char(self):
self.lines[reference_field] = False
class ALine(models.Model):
_name = 'a.line'
parent_id = fields.Many2one('a')
reference_field = fields.Reference([('res.uses', 'users')])
Impacted versions: [13.0][14.0]
Steps to reproduce: clear the value of reference field in onchange methods
return None for no value record and use empty dict for one2many fields to compare None with None
https://github.com/odoo/odoo/blob/14.0/odoo/fields.py#L2461
https://github.com/odoo/odoo/blob/14.0/odoo/models.py#L6123
https://github.com/odoo/odoo/blob/14.0/odoo/models.py#L6091
It makes clear for reference in one2many field doesn't work
why not reference field return False for no value record
Current behavior: clear for reference doesn't work
Expected behavior: clear for reference work
Video/Screenshot link (optional):
Support ticket number submitted via odoo.com/help (optional):
I ran into the same problem :(
Hi @pedrobaeza ,here is the video link
The video is not helping, doing a lot of unexplained things very fast I'm afraid.
The video is not helping, doing a lot of unexplained things very fast I'm afraid.
Sorry, I'm not very good at this
I recorded a new vedio, please
I think the problem is with the assignation itself. Use:
self.lines.update({"reference_field": False})
I think the problem is with the assignation itself. Use:
self.lines.update({"reference_field": False})
use update method
It doesn't work, onchange snapshot diff method still compare None with None
And what about using self.lines.update({"reference_field": ""})
?
And what about using
self.lines.update({"reference_field": ""})
?
"" is Odoo Server Error
In convert_to_record method of class Reference
def convert_to_record(self, value, record):
# value in [False, None], return None, what make onchange diff doesn't work
if value:
res_model, res_id = value.split(',')
return record.env[res_model].browse(int(res_id))
return None
What is the impact of return false in convert_to_record method of class Reference ?
Impacted versions: [13.0][14.0]
Steps to reproduce: clear the value of reference field in onchange methods
return None for no value record and use empty dict for one2many fields to compare None with None
https://github.com/odoo/odoo/blob/14.0/odoo/fields.py#L2461
https://github.com/odoo/odoo/blob/14.0/odoo/models.py#L6123
https://github.com/odoo/odoo/blob/14.0/odoo/models.py#L6091
It makes clear for reference in one2many field doesn't work
why not reference field return False for no value record
Current behavior: clear for reference doesn't work
Expected behavior: clear for reference work
Video/Screenshot link (optional):
Support ticket number submitted via odoo.com/help (optional):