fix date in create_sale function
This commit is contained in:
parent
dbd53acd13
commit
dd9f486bbf
42
sale.py
42
sale.py
|
@ -1,18 +1,23 @@
|
||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
import math
|
import math
|
||||||
from operator import attrgetter
|
from datetime import date, datetime, timedelta
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from operator import attrgetter
|
||||||
|
|
||||||
from sql import Table
|
from sql import Table
|
||||||
from sql.aggregate import Sum
|
from sql.aggregate import Sum
|
||||||
from datetime import date, timedelta, datetime
|
|
||||||
|
|
||||||
from trytond.pool import Pool, PoolMeta
|
|
||||||
from trytond.transaction import Transaction
|
|
||||||
from trytond.model import fields
|
from trytond.model import fields
|
||||||
from trytond.modules.dash.dash import DashAppBase
|
from trytond.modules.dash.dash import DashAppBase
|
||||||
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
from .process_pay import (
|
from .process_pay import (
|
||||||
get_pay, get_response_pay, process_response, get_dict_response_pay)
|
get_dict_response_pay,
|
||||||
|
get_pay,
|
||||||
|
get_response_pay,
|
||||||
|
process_response,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Sale(metaclass=PoolMeta):
|
class Sale(metaclass=PoolMeta):
|
||||||
|
@ -42,6 +47,10 @@ class Sale(metaclass=PoolMeta):
|
||||||
field_status_order = 'status_order' in Line._fields
|
field_status_order = 'status_order' in Line._fields
|
||||||
records = cls.browse([args['id']])
|
records = cls.browse([args['id']])
|
||||||
lines_action = args.get('lines')
|
lines_action = args.get('lines')
|
||||||
|
table = args.get('table_assigned')
|
||||||
|
|
||||||
|
if table:
|
||||||
|
cls.write(records, {'table_assigned': table})
|
||||||
if lines_action:
|
if lines_action:
|
||||||
for action, lines in lines_action:
|
for action, lines in lines_action:
|
||||||
# action, lines = lines_tuple
|
# action, lines = lines_tuple
|
||||||
|
@ -50,6 +59,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
product = Product(line['product'])
|
product = Product(line['product'])
|
||||||
cls._add_values(product.template, line, field_status_order)
|
cls._add_values(product.template, line, field_status_order)
|
||||||
cls.write(records, args)
|
cls.write(records, args)
|
||||||
|
if table or lines_action:
|
||||||
res = {
|
res = {
|
||||||
'record': {'id': args['id']},
|
'record': {'id': args['id']},
|
||||||
'msg': 'Pedido Actualizado!!!',
|
'msg': 'Pedido Actualizado!!!',
|
||||||
|
@ -76,6 +86,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
Party = pool.get('party.party')
|
Party = pool.get('party.party')
|
||||||
User = pool.get('res.user')
|
User = pool.get('res.user')
|
||||||
Line = pool.get('sale.line')
|
Line = pool.get('sale.line')
|
||||||
|
Date = pool.get('ir.date')
|
||||||
ctx = Transaction().context
|
ctx = Transaction().context
|
||||||
if ctx.get('shop'):
|
if ctx.get('shop'):
|
||||||
shop = Shop(ctx['shop'])
|
shop = Shop(ctx['shop'])
|
||||||
|
@ -156,7 +167,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
|
|
||||||
description = args.get('description', '')
|
description = args.get('description', '')
|
||||||
comment = args.get('comment', '')
|
comment = args.get('comment', '')
|
||||||
today = date.today()
|
today = Date.today()
|
||||||
to_create = {
|
to_create = {
|
||||||
'shop': shop.id,
|
'shop': shop.id,
|
||||||
'invoice_type': invoice_type,
|
'invoice_type': invoice_type,
|
||||||
|
@ -420,13 +431,15 @@ class Sale(metaclass=PoolMeta):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dash_create_order_call(cls, args):
|
def dash_create_order_call(cls, args):
|
||||||
Shop = Pool().get('sale.shop')
|
pool = Pool()
|
||||||
Product = Pool().get('product.product')
|
Shop = pool.get('sale.shop')
|
||||||
Party = Pool().get('party.party')
|
Product = pool.get('product.product')
|
||||||
OrderStatusTime = Pool().get('sale.order_status.time')
|
Party = pool.get('party.party')
|
||||||
Configuration = Pool().get('sale.configuration')
|
Date = pool.get('ir.date')
|
||||||
|
OrderStatusTime = pool.get('sale.order_status.time')
|
||||||
|
Configuration = pool.get('sale.configuration')
|
||||||
config = Configuration(1)
|
config = Configuration(1)
|
||||||
User = Pool().get('res.user')
|
User = pool.get('res.user')
|
||||||
ctx = Transaction().context
|
ctx = Transaction().context
|
||||||
|
|
||||||
user = User(ctx.get('user'))
|
user = User(ctx.get('user'))
|
||||||
|
@ -485,8 +498,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
|
|
||||||
description = args.get('description', '')
|
description = args.get('description', '')
|
||||||
comment = args.get('comment', '')
|
comment = args.get('comment', '')
|
||||||
date_ = datetime.now() - timedelta(hours=5)
|
today = Date.today()
|
||||||
today = date(date_.year, date_.month, date_.day)
|
|
||||||
to_create = {
|
to_create = {
|
||||||
'consumer': args['consumer'],
|
'consumer': args['consumer'],
|
||||||
'source': args['source'],
|
'source': args['source'],
|
||||||
|
|
Loading…
Reference in New Issue