Minor fix

This commit is contained in:
oscar alvarez 2023-09-03 07:41:51 -05:00
parent 5ff530c982
commit a088ad46e9
1 changed files with 13 additions and 11 deletions

24
sale.py
View File

@ -6,13 +6,13 @@ from decimal import Decimal
from sql import Table
from sql.aggregate import Sum
from datetime import date, timedelta, datetime
from time import sleep
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.model import fields
from trytond.modules.dash.dash import DashAppBase
from .process_pay import get_pay, get_response_pay, process_response, get_dict_response_pay
from .process_pay import (
get_pay, get_response_pay, process_response, get_dict_response_pay)
class Sale(metaclass=PoolMeta):
@ -31,6 +31,7 @@ class Sale(metaclass=PoolMeta):
@classmethod
def send_order(cls, args, ctx=None):
Product = Pool().get('product.product')
if args['id'] <= 0:
res = cls.create_sale(args, ctx)
return res
@ -41,6 +42,8 @@ class Sale(metaclass=PoolMeta):
if ln[0] == 'create' and len(ln[1]) > 0:
for p in ln[1]:
p['status_order'] = 'requested'
product = Product(p['product'])
p['description'] = product.template.name
cls.write(records, args)
res = {
'record': {'id': args['id']},
@ -56,7 +59,6 @@ class Sale(metaclass=PoolMeta):
Party = Pool().get('party.party')
User = Pool().get('res.user')
ctx = Transaction().context
print(args, 'ctx')
if ctx.get('shop'):
shop = Shop(ctx['shop'])
if args.get('shop'):
@ -74,7 +76,6 @@ class Sale(metaclass=PoolMeta):
if nested_values:
lines = nested_values
for v in lines:
print('Value line to create =====>', v)
if v.get('id'):
del v['id']
if v.get('amount'):
@ -93,9 +94,10 @@ class Sale(metaclass=PoolMeta):
elif v.get('discount'):
del v['discount']
v['unit'] = product.template.default_uom.id
v['description'] = product.name
taxes = list(product.account_category.customer_taxes_used)
template = product.template
v['unit'] = template.default_uom.id
v['description'] = template.name
taxes = list(template.account_category.customer_taxes_used)
taxes_ids = [t.id for t in taxes]
v['taxes'] = [('add', taxes_ids)]
@ -105,17 +107,17 @@ class Sale(metaclass=PoolMeta):
price_list = args.get('price_list', None)
try:
# option kid
# for kid
party, = Party.browse([args['party']['id']])
except Exception:
# option fastkid
# for fastkid
party, = Party.browse([args['party']])
if args.get('shipment_address'):
try:
# option kid
# for kid
shipment_address_id = args.get('shipment_address')['id']
except Exception:
# option fastkid
# for fastkid
shipment_address_id = args.get('shipment_address')
else:
shipment_address_id = party.addresses[0].id