the code does not return any value, these are the models.
I wish that tcorr = tcod + A001
ex: tcorr = cod01 + A001
or tcorr = cod02 + A001, where cod01 (changes according to the field selection tdoc = many2one)
# -*- coding: utf-8 -*-
from odoo import _, api, fields, models
class einvoice_catalog_01(models.Model):
_name = "einvoice.catalog.01"
_description = 'Codigo de Tipo '
code = fields.Char(string='Codigo', size=4, index=True, required=True)
name = fields.Char(string='Descripcion', size=128, index=True, required=True)
@api.multi
@api.depends('code', 'name')
def name_get(self):
result = []
for table in self:
l_name = table.code and table.code + ' - ' or ''
l_name += table.name
result.append((table.id, l_name ))
return result
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class inv13(models.Model):
_inherit='account.invoice'
tdoc=fields.Many2one('einvoice.catalog.01')
seri=fields.Char(string="seri")
corr=fields.Char(string="Correlativo")
tcorr=fields.Char(string="Union All")
@api.onchange(tdoc)
def change_tdoc(self):
self.seri="A001"
self.tcorr=str(self.tdoc.code)+seri