Minor fix

This commit is contained in:
Oscar Alvarez 2021-01-21 14:35:43 -05:00
parent 1a70013d4d
commit 45343dcd89
2 changed files with 22 additions and 11 deletions

31
sale.py
View File

@ -1,7 +1,7 @@
# 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 __future__ import unicode_literals
from datetime import date
from datetime import date, datetime
from trytond.pool import PoolMeta, Pool
from trytond.model import fields
from trytond.pyson import Eval
@ -24,18 +24,22 @@ class Sale(metaclass=PoolMeta):
consumer = fields.Many2One('party.consumer', 'Consumer')
table_assigned = fields.Many2One('sale.shop.table', 'Table Assigned',
domain=[
('shop', '=', Eval('shop'))
('shop', '=', Eval('shop')),
])
productions = fields.Function(fields.One2Many('production', None, 'Productions'), 'get_productions')
delivery_time = fields.Numeric('Delivery Time (Min)', help="In Minutes")
# kind = fields.Selection([
# ('', ''),
# ('delivery', 'Delivery'),
# ('take_away', 'Take Away'),
# ('to_table', 'To Table'),
# ], 'Kind Order')
# kind_string = kind.translated('kind')
shipping_time = fields.Time('Shipping Time')
order_status = fields.Selection([
('', ''),
('draft', 'Draft'),
('commanded', 'Commanded'),
('in_preparation', 'In Preparation'),
('dispatched', 'Dispatched'),
('delivered', 'Delivered'),
('rejected', 'Rejected'),
('cancelled', 'Cancelled'),
], 'Order Status')
order_status_string = order_status.translated('order_status')
shipping_time = fields.DateTime('Shipping Time')
waiting_time = fields.Function(fields.Integer('Shipping Time',
help="In Minutes"), 'get_waiting_time')
@ -48,9 +52,14 @@ class Sale(metaclass=PoolMeta):
'message_error': 'Error: %s',
},)
@staticmethod
def default_order_status():
return 'draft'
def get_waiting_time(self, name=None):
now = datetime.now()
if self.state in ('draft', 'quotation', 'confirmed', 'processing'):
delta = int((self.write_date - self.create_date).seconds / 60)
delta = int((now - self.create_date).seconds / 60)
return delta
@classmethod

View File

@ -9,6 +9,8 @@ copyright notices and license terms. -->
<field name="kind"/>
<label name="consumer"/>
<field name="consumer"/>
<label name="order_status"/>
<field name="order_status"/>
<label name="table_assigned"/>
<field name="table_assigned" widget="selection"/>
<label name="delivery_time"/>