Hi, i have this problem with this code that worked in past versions of Odoo:
The objetive is take the sale's date and create visitthe objective is to take the sale date and create a plan for automatic visits, 2 visits per year for three years
class garantias(models.Model):
_name = 'itriplee.garantias'
_rec_name = 'folio'
folio = fields.Integer('Folio', required=True)
cliente = fields.Many2one('res.partner', 'Cliente')
equipo = fields.Many2one('itriplee.equipos', 'Equipo')
serie = fields.Char('Numero de Serie', related='equipo.name', readonly=True)
factura = fields.Char('Numero de Factura', related='equipo.factura', readonly=True)
modelo = fields.Char('Modelo', related='equipo.modelo.name', readonly=True)
marca = fields.Char('Marca', related='equipo.marca', readonly=True)
tipo = fields.Char('Tipo', related='equipo.tipo', readonly=True)
fecha_de_venta = fields.Date('Fecha de Venta', related='equipo.venta', readonly=True)
visitas = fields.One2many('itriplee.servicio', 'garantia_asociada', 'Visitas')
observaciones = fields.Text('Observaciones')
valoracion = fields.Text('Valoración para Poliza')
@api.model
def create(self, vals):
obj_visita = self.pool.get('itriplee.servicio')
obj = self.env['itriplee.garantias']
cliente = obj.cliente.id
fecha_compra = obj.equipo.venta
fm = ('%Y-%m-%d')
cantidad_meses = 6
ind = 0
now = datetime.now()
now_str = now.strftime(fm)
now_int = datetime.strptime(now_str, fm)
# fecha_compra_original = datetime.strptime(fecha_compra, fm)
fecha_compra_inicial = datetime.strptime(fecha_compra, fm)
while ind < cantidad_meses:
fecha_6_meses = fecha_compra_inicial + relativedelta(months=6)
if fecha_6_meses >= now_int:
obj_visita.create({'cliente':cliente,'visita':fecha_6_meses,'estado':'confirmar','visitas':obj.id},context=None)
ind = ind + 1
fecha_compra_inicial = fecha_6_meses
return True
And that gave me this error:
Traceback (most recent call last): File "/home/openerp/odoo-dev/odoo/odoo/http.py", line 651, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/openerp/odoo-dev/odoo/odoo/http.py", line 310, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/home/openerp/odoo-dev/odoo/odoo/tools/pycompat.py", line 87, in reraise raise value File "/home/openerp/odoo-dev/odoo/odoo/http.py", line 693, in dispatch result = self._call_function(**self.params) File "/home/openerp/odoo-dev/odoo/odoo/http.py", line 342, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/openerp/odoo-dev/odoo/odoo/service/model.py", line 97, in wrapper return f(dbname, *args, **kwargs) File "/home/openerp/odoo-dev/odoo/odoo/http.py", line 335, in checked_call result = self.endpoint(*a, **kw) File "/home/openerp/odoo-dev/odoo/odoo/http.py", line 937, in __call__ return self.method(*args, **kw) File "/home/openerp/odoo-dev/odoo/odoo/http.py", line 515, in response_wrap response = f(*args, **kw) File "/home/openerp/odoo-dev/odoo/addons/web/controllers/main.py", line 934, in call_kw return self._call_kw(model, method, args, kwargs) File "/home/openerp/odoo-dev/odoo/addons/web/controllers/main.py", line 926, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/openerp/odoo-dev/odoo/odoo/api.py", line 687, in call_kw return call_kw_model(method, model, args, kwargs) File "/home/openerp/odoo-dev/odoo/odoo/api.py", line 672, in call_kw_model result = method(recs, *args, **kwargs) File "/home/openerp/odoo-dev/odoo/addons/itriplee/models/garantias.py", line 83, in create fecha_compra_inicial = datetime.strptime(fecha_compra, fm) TypeError: strptime() argument 1 must be str, not bool
i don't get it, can you help me?