0
votes

I have two custom modules in odoo: segus.py (has a record of codes used as a source of information) reporte.py (use the fields registered in the module segus.py) I am extracting the following fields: sCodComp using many2one and the field decrTecn using related up here all right

from odoo import models, fields
class Reporte(models.Model):
    _name = 'rep.oper' 
    segus1 = fields.Many2one('segus.list','SEGUS 1', required=True)
    decrTecn = fields.Text(related='segus1.sDescr', store=True)

from odoo import models, fields
class Segus(models.Model):
    _name = 'segus.list'
    _rec_name = 'sNom'
    _description = 'Codes procedures'
    sCodComp = fields.Char('component code')
    sDescr = fields.Text('description procedures')

I would like to know how to make an editable copy in Reporte module of the Segus.sDescr field, because this original must not be modified.

Thanks

1

1 Answers

1
votes

You should use onchange not related fields, if you need to change value without change original value. try this:

@api.multi
    def onchange_segus1(self,segus1):
    values          = {}
        segus_obj    = self.env['segus.list']
    if segus1:
        data = segus_ob.browse(segus1).sDescr
        values  = {
            'decrTecn' : data       
        }
    return {'value': values} 

and add in xml: on_change="onchange_get_all_mark(segus1)", in fields segus1