This commit is contained in:
oscar alvarez 2022-11-12 09:11:02 -05:00
parent 6f923c12f7
commit 5967fc4935
2 changed files with 28 additions and 49 deletions

74
sale.py
View File

@ -12,8 +12,6 @@ from trytond.transaction import Transaction
from trytond.model import fields
from trytond.modules.dash.dash import DashAppBase
TODAY = date.today()
class Sale(metaclass=PoolMeta):
__name__ = 'sale.sale'
@ -79,12 +77,13 @@ class Sale(metaclass=PoolMeta):
description = args.get('description', '')
comment = args.get('comment', '')
today = date.today()
to_create = {
'shop': shop.id,
'invoice_type': 'P',
'company': shop.company.id,
'party': args['party']['id'],
'sale_date': TODAY,
'sale_date': today,
'shipment_date': shipment_date,
'shipment_address': shipment_address_id,
'invoice_address': shipment_address_id,
@ -231,6 +230,7 @@ class Sale(metaclass=PoolMeta):
cls._set_line(v, context)
party = shop.party
today = date.today()
to_create = {
'shop': shop.id,
'party': party.id,
@ -239,8 +239,8 @@ class Sale(metaclass=PoolMeta):
'shipment_address': party.addresses[0].id,
'invoice_address': party.addresses[0].id,
'company': shop.company.id,
'sale_date': TODAY,
'shipment_date': TODAY,
'sale_date': today,
'shipment_date': today,
'kind': 'to_table',
'price_list': shop.price_list,
'payment_term': shop.payment_term.id,
@ -333,9 +333,10 @@ class Sale(metaclass=PoolMeta):
Period = pool.get('account.period')
Currency = pool.get('currency.currency')
res = {}
today = date.today()
periods = Period.search([
('start_date', '<=', TODAY),
('end_date', '>=', TODAY),
('start_date', '<=', today),
('end_date', '>=', today),
('type', '=', 'standard')
])
if not periods:
@ -356,10 +357,11 @@ class Sale(metaclass=PoolMeta):
dates = {'period': period}
value = cls._get_sales_report(dates, currency_id, in_thousands=True)
month_name = today.strftime("%b %Y")
res = {
'value': value,
'selector': selector,
'header_meta': str(TODAY),
'header_meta': month_name,
'desc': 'In thousands',
'desc_meta': currency.code,
}
@ -371,10 +373,10 @@ class Sale(metaclass=PoolMeta):
pool = Pool()
Fiscalyear = pool.get('account.fiscalyear')
Currency = pool.get('currency.currency')
today = date.today()
fiscalyear, = Fiscalyear.search([
('start_date', '<=', TODAY),
('end_date', '>=', TODAY),
('start_date', '<=', today),
('end_date', '>=', today),
], limit=1)
if not fiscalyear:
return {}
@ -410,10 +412,10 @@ class Sale(metaclass=PoolMeta):
pool = Pool()
Fiscalyear = pool.get('account.fiscalyear')
Currency = pool.get('currency.currency')
today = date.today()
fiscalyear, = Fiscalyear.search([
('start_date', '<=', TODAY),
('end_date', '>=', TODAY),
('start_date', '<=', today),
('end_date', '>=', today),
], limit=1)
if not fiscalyear:
return {}
@ -442,7 +444,7 @@ class Sale(metaclass=PoolMeta):
res = {
'value': sum(values),
'selector': selector,
'header_meta': str(TODAY),
'header_meta': fiscalyear.name,
'desc': 'In thousands',
'desc_meta': currency.code,
}
@ -453,24 +455,24 @@ class Sale(metaclass=PoolMeta):
# Dash Report
pool = Pool()
Currency = pool.get('currency.currency')
currency_id = Transaction().context.get('currency')
if args.get('currency'):
currency_id = args.get('currency')
currency = Currency(currency_id)
currency = Currency(currency_id)
today = date.today()
dates = {
'start_date': TODAY,
'end_date': TODAY
'start_date': today,
'end_date': today
}
yesterday = str(TODAY - timedelta(days=1))
yesterday = str(today - timedelta(days=1))
selector = {yesterday: 'yesterday'}
values = cls._get_sales_report(dates, currency_id, True)
res = {
'value': values,
'selector': selector,
'header_meta': str(TODAY),
'header_meta': str(today),
'desc': 'In thousands',
'desc_meta': currency.code,
}
@ -481,10 +483,10 @@ class Sale(metaclass=PoolMeta):
pool = Pool()
Fiscalyear = pool.get('account.fiscalyear')
Currency = pool.get('currency.currency')
today = date.today()
fiscalyear, = Fiscalyear.search([
('start_date', '<=', TODAY),
('end_date', '>=', TODAY),
('start_date', '<=', today),
('end_date', '>=', today),
], limit=1)
if not fiscalyear:
return {}
@ -535,27 +537,11 @@ class AppDelivery(DashAppBase):
class AppTakeOrder(DashAppBase):
'App Take Order'
__name__ = 'dash.app.take_order'
# company = fields.Many2One('company.company', 'Company', required=True)
# code = fields.Char('Code')
@classmethod
def __setup__(cls):
super(AppTakeOrder, cls).__setup__()
@staticmethod
def default_company():
return Transaction().context.get('company') or None
class AppOrderViewer(DashAppBase):
'App Order Viewer'
__name__ = 'dash.app.order_viewer'
# company = fields.Many2One('company.company', 'Company', required=True)
# code = fields.Char('Code')
@classmethod
def __setup__(cls):
super(AppOrderViewer, cls).__setup__()
@staticmethod
def default_company():
@ -573,11 +559,3 @@ class AppSaleOrder(DashAppBase):
class AppSelfServiceSale(DashAppBase):
'App Self Service Sale'
__name__ = 'dash.app.self_service_sale'
@classmethod
def __setup__(cls):
super(AppSelfServiceSale, cls).__setup__()
@staticmethod
def default_company():
return Transaction().context.get('company') or None

View File

@ -1,5 +1,5 @@
[tryton]
version=6.0.9
version=6.0.10
depends:
party
product
@ -9,6 +9,7 @@ depends:
sale_salesman
commission
dash
sale_goal
xml:
sale.xml
reports.xml