Add dash_create

This commit is contained in:
oscar 2021-03-31 16:17:46 -05:00
parent 91d40fdf10
commit ccd76952a2
3 changed files with 36 additions and 3 deletions

View file

@ -7,4 +7,4 @@ import sale
def register():
Pool.register(
sale.Sale,
module='dashboard_sale', type_='model')
module='dash_sale', type_='model')

33
sale.py
View file

@ -13,6 +13,39 @@ __all__ = ['Sale']
class Sale(metaclass=PoolMeta):
__name__ = 'sale.sale'
@classmethod
def __setup__(cls):
super(Sale, cls).__setup__()
@classmethod
def dash_quote(cls, args, ctx):
Shop = Pool().get('sale.shop')
shop_id = ctx['shop']
shop = Shop(shop_id)
to_create = {
'shop': shop_id,
'invoice_type': 'P',
'company': shop.company.id,
'party': args['party']['id'],
'sale_date': args['sale_date'],
'shipment_address': args['shipment_address']['id'],
'invoice_address': args['shipment_address']['id'],
'agent': args['agent']['id'],
'payment_term': shop.payment_term.id,
'state': 'draft',
'lines': [('create', args['lines'])],
}
sale, = cls.create([to_create])
cls.quote([sale])
res = {
'record': {'id': sale.id, 'number': sale.number},
'msg': 'sucess_order',
'status': 'ok',
'open_modal': True,
}
return res
@classmethod
def report_sales_day(cls, args, ctx):
pass

View file

@ -1,9 +1,9 @@
[tryton]
version=5.0.0
version=5.0.1
depends:
party
product
account
sale
dashboard
dash
xml: