This commit is contained in:
oscar alvarez 2022-11-17 12:34:18 -05:00
parent 4be8748bd0
commit 98e5413fb6
1 changed files with 8 additions and 17 deletions

25
sale.py
View File

@ -1,6 +1,5 @@
# This file is part of purchase_discount module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
# 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 decimal import Decimal
from sql import Table
@ -49,8 +48,6 @@ class Sale(metaclass=PoolMeta):
if v.get('discount') and v['discount'] != '':
v['discount'] = Decimal(v['discount'])/100
# unit_price = product.list_price - (product.list_price * Decimal(v['discount']))
# v['unit_price'] = Decimal(unit_price).quantize(Decimal(str(10.0 ** -4)))
elif v.get('discount'):
del v['discount']
v['unit'] = product.template.default_uom.id
@ -158,12 +155,6 @@ class Sale(metaclass=PoolMeta):
with Transaction().set_context(context):
unit_price = product.list_price
# if args.get('quantity'):
# quantity = int(args.get('quantity'))
# else:
# quantity = 1
# percent_commission = 0
if price_list_id:
price_lines = PriceListLine.search([
('price_list', '=', price_list_id),
@ -175,7 +166,7 @@ class Sale(metaclass=PoolMeta):
unit_price = Decimal(eval(price_line.formula))
# percent_commission = price_line.price_list.percent_commission
#ADD TAXES
# ADD TAXES
# taxes_ids = [t.id for t in product.customer_taxes_used]
# res = cls.get_price_with_tax([line], ['amount_w_tax', 'unit_price_w_tax'])
res = {
@ -211,7 +202,6 @@ class Sale(metaclass=PoolMeta):
product = Product(val['product'])
with Transaction().set_context(context):
unit_price = product.list_price
# unit_price = product.template.list_price
unit_price = unit_price.quantize(Decimal(str(10.0 ** -4)))
val['unit_price'] = unit_price
val['base_price'] = unit_price
@ -413,8 +403,9 @@ class Sale(metaclass=PoolMeta):
labels.append(month)
dates = {'period': p}
val = cls._get_sales_report(dates, currency_id, True)
if val > 0:
values.append(val)
if not val:
val = 0
values.append(val)
res = {
'values': values,
@ -501,7 +492,7 @@ class Sale(metaclass=PoolMeta):
def report_fulfillment_goal_year(cls, args, ctx=None):
pool = Pool()
Fiscalyear = pool.get('account.fiscalyear')
Currency = pool.get('currency.currency')
# Currency = pool.get('currency.currency')
today = date.today()
fiscalyear, = Fiscalyear.search([
('start_date', '<=', today),
@ -515,7 +506,7 @@ class Sale(metaclass=PoolMeta):
if args.get('currency'):
currency_id = args.get('currency')
currency = Currency(currency_id)
# currency = Currency(currency_id)
values = []
labels = []