[FIX] various: adapt code to new datetime fields

Some code was still using the date and datetime fields as if they were
strings, but they are now dates and datetimes
This commit is contained in:
RomainLibert
2018-08-23 16:03:55 +02:00
parent 0562fc0ffd
commit 3f2bc7b11f
4 changed files with 4 additions and 5 deletions
+1 -2
View File
@@ -18,8 +18,7 @@ def random_token():
return ''.join(random.SystemRandom().choice(chars) for _ in range(20))
def now(**kwargs):
dt = datetime.now() + timedelta(**kwargs)
return fields.Datetime.to_string(dt)
return datetime.now() + timedelta(**kwargs)
class ResPartner(models.Model):
+1 -1
View File
@@ -88,7 +88,7 @@ class StockRule(models.Model):
seller = product_id._select_seller(
partner_id=partner,
quantity=product_qty,
date=fields.Date.to_string(schedule_date),
date=schedule_date and schedule_date.date(),
uom_id=product_uom)
return schedule_date - relativedelta(days=int(seller.delay))
+1 -1
View File
@@ -220,7 +220,7 @@ class SaleOrderLine(models.Model):
supplierinfo = self.product_id._select_seller(
partner_id=purchase_order.partner_id,
quantity=purchase_qty_uom,
date=purchase_order.date_order, # and purchase_order.date_order[:10],
date=purchase_order.date_order and purchase_order.date_order.date(), # and purchase_order.date_order[:10],
uom_id=self.product_id.uom_po_id
)
fpos = purchase_order.fiscal_position_id
+1 -1
View File
@@ -924,7 +924,7 @@ class Orderpoint(models.Model):
# These days will be substracted when creating the PO
days += self.product_id._select_seller(
quantity=product_qty,
date=fields.Date.to_string(start_date),
date=start_date,
uom_id=self.product_uom).delay or 0.0
date_planned = start_date + relativedelta.relativedelta(days=days)
return date_planned.strftime(DEFAULT_SERVER_DATETIME_FORMAT)