This commit is contained in:
oscar alvarez 2022-11-03 23:20:14 -05:00
parent 4636aa4490
commit 6f2ea1ba21
7 changed files with 34 additions and 48 deletions

View File

@ -3,7 +3,6 @@
from trytond.pool import Pool
from . import sale
from . import dash
from . import product
def register():
@ -15,5 +14,4 @@ def register():
sale.AppOrderViewer,
sale.AppSelfServiceSale,
dash.DashApp,
# product.Product,
module='dash_sale', type_='model')

View File

@ -1,17 +1,9 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from decimal import Decimal
from datetime import date
from trytond.model import fields, ModelSQL, ModelView
from trytond.pool import PoolMeta, Pool
from trytond.transaction import Transaction
from trytond.wizard import Wizard, StateTransition, StateView, Button
from trytond.model import fields
from trytond.pool import PoolMeta
class Product(metaclass=PoolMeta):
__name__ = 'product.product'
short_name = fields.Char('Short Name')
# def get_rec_name(self, name=None):
# super(Product, self).get_rec_name(name=name)
# return self.template.name

23
reports.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="dash.report" id="dash_report_sales_month">
<field name="name">Sales Month</field>
<field name="model">sale.sale</field>
<field name="type">card_info</field>
<field name="method">report_sales_month</field>
<field name="in_thousands">True</field>
</record>
<record model="dash.report" id="dash_report_sales_by_month">
<field name="name">Sales By Month</field>
<field name="model">sale.sale</field>
<field name="type">bar</field>
<field name="method">report_sales_by_month</field>
<field name="in_thousands">True</field>
</record>
</data>
</tryton>

22
sale.py
View File

@ -8,18 +8,13 @@ from sql.aggregate import Sum
from datetime import date
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.model import ModelView, ModelSQL, fields
from trytond.model import fields
from trytond.modules.dash.dash import DashAppBase
class Sale(metaclass=PoolMeta):
__name__ = 'sale.sale'
@classmethod
def __setup__(cls):
super(Sale, cls).__setup__()
@classmethod
def dash_faster_process(cls, records):
for rec in records:
@ -213,9 +208,6 @@ class Sale(metaclass=PoolMeta):
def command(cls, args):
Shop = Pool().get('sale.shop')
ShopTable = Pool().get('sale.shop.table')
Product = Pool().get('product.product')
Party = Pool().get('party.party')
Line = Pool().get('sale.line')
User = Pool().get('res.user')
context = Transaction().context
today = date.today()
@ -242,7 +234,7 @@ class Sale(metaclass=PoolMeta):
to_create = {
'shop': shop.id,
'party': party.id,
'invoice_type':'P',
'invoice_type': 'P',
'table_assigned': args['table_assigned']['id'],
'shipment_address': party.addresses[0].id,
'invoice_address': party.addresses[0].id,
@ -298,7 +290,6 @@ class Sale(metaclass=PoolMeta):
except Exception as e:
print(e, 'error')
@classmethod
def report_sales_day(cls, args, ctx):
pass
@ -346,7 +337,6 @@ class Sale(metaclass=PoolMeta):
if not periods:
return res
report = args.get('report', None)
period = periods[0]
selector_periods = Period.search([
('fiscalyear', '=', period.fiscalyear.id),
@ -362,7 +352,8 @@ class Sale(metaclass=PoolMeta):
selector = {p.id: p.name for p in selector_periods}
description = currency.code
value = cls._get_sales_in_period(period, currency_id, in_thousands=True)
value = cls._get_sales_in_period(
period, currency_id, in_thousands=True)
res = {
'value': value,
@ -398,7 +389,6 @@ class Sale(metaclass=PoolMeta):
values = []
labels = []
report = args.get('report', None)
for p in periods:
val = cls._get_sales_in_period(p, currency_id, True)
if val > 0:
@ -468,9 +458,9 @@ class AppOrderViewer(DashAppBase):
class AppSaleOrder(DashAppBase):
'App Sale Order'
__name__ = 'dash.app.sale_order'
allow_discount = fields.Boolean('Allow Discount')
allow_manual_pricing = fields.Boolean('Allow Manual Pricing', help='Allow manual pricing to user')
allow_manual_pricing = fields.Boolean('Allow Manual Pricing',
help='Allow manual pricing to user')
class AppSelfServiceSale(DashAppBase):

View File

@ -28,6 +28,7 @@ def get_require_version(name):
major_version, minor_version + 1)
return require
config = ConfigParser()
config.readfp(open('tryton.cfg'))
info = dict(config.items('tryton'))

View File

@ -1,5 +1,5 @@
[tryton]
version=6.0.6
version=6.0.7
depends:
party
product
@ -11,3 +11,4 @@ depends:
dash
xml:
sale.xml
reports.xml

View File

@ -1,19 +0,0 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath
expr="/form/notebook/page[@id='sale']/field[@name='sale_price_list']"
position="after">
<!-- remove temporaly fix me -->
<!-- <label name="zone"/>
<field name="zone"/> -->
</xpath>
<xpath
expr="/form/notebook/page[@id='sale']/field[@name='sale_price_list']"
position="after">
<label name="agent"/>
<field name="agent"/>
</xpath>
</data>