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