I have a big question:
I created 2 models:
status = [(1,'Vigente'),(2,'Caducado')]
class DateOfert(models.Model):
_name = 'date.ofert'
ofert_status = fields.Selection(status , string='Estatus Comercial')
date_i = fields.Date(string='Fecha Inicial ')
date_f = fields.Date(string='Fecha Final')
ofert_c = fields.Many2many('comercial.ofert',string='Oferta Comercial')
class ComercialOfert(models.Model):
_name = "comercial.ofert"
n_dues = fields.Integer('N° de cuotas', size=2, required=True, help="Ingrese la cantidad de cuotas")
money_i = fields.Float('Monto Inicial', required=True, help="Ingrese el precio inicial de la oferta")
money_f = fields.Float('Monto Final', required=True, help="Ingrese hasta el precion final de la oferta comercial")
t_pay = fields.Many2one('account.payment.term', 'N° de Dias de creditos', select=True)
discount = fields.Integer('% Descuento', size=2, required=True)
Below I created in a decorator in the method I have the following segment of the quote that I want to try to get money_i from the date.ofert model that the attribute is ofert_c is type Many2many.
context = self.env['date.ofert'].search([])
for element in context:
if element.ofert_status == 1:
print(element.ofert_c.money_i)
and it shows me this error:
File "C:\proy\Odoo 10.0\server\odoo\fields.py", line 904, in __get__
File "C:\proy\Odoo 10.0\server\odoo\models.py", line 4823, in ensure_one
ValueError: Expected singleton: comercial.ofert(1, 2)
Ayudaaaaaaaaaaaaaaaa !!!