add model order status time

This commit is contained in:
Wilson Gomez 2023-05-05 11:18:01 -05:00
parent 8d2fc9a05a
commit 1f9d2848c1
4 changed files with 36 additions and 13 deletions

View File

@ -22,6 +22,7 @@ def register():
sale.SaleLineHistoryDelete,
sale.SaleLineHistoryDeleteStart,
sale.SaleMove,
sale.OrderStatusTime,
shop.SaleShop,
production.Production,
product.ProductMixOption,

41
sale.py
View File

@ -4,7 +4,7 @@ from __future__ import unicode_literals
from datetime import date, datetime
from sql import Table
from trytond.pool import PoolMeta, Pool
from trytond.model import fields, ModelSQL, ModelView
from trytond.model import fields, ModelSQL, ModelView, DictSchemaMixin
from trytond.modules.product import price_digits
from trytond.pyson import Eval
from trytond.transaction import Transaction
@ -26,6 +26,18 @@ KIND = [
('to_table', 'To Table')
]
OPTIONS_STATUS = [
('', ''),
('draft', 'Draft'),
('requested', 'Requested'),
('commanded', 'Commanded'),
('in_preparation', 'In Preparation'),
('dispatched', 'Dispatched'),
('delivered', 'Delivered'),
('rejected', 'Rejected'),
('cancelled', 'Cancelled'),
]
class SaleMove(ModelSQL):
"Sale - Stock Move"
@ -47,21 +59,12 @@ class Sale(metaclass=PoolMeta):
productions = fields.Function(fields.One2Many('production', None, 'Productions'), 'get_productions')
production_moves = fields.Many2Many('sale.sale-stock.move', 'sale', 'move', 'Production Moves')
delivery_time = fields.Numeric('Delivery Time (Min)', help="In Minutes")
order_status = fields.Selection([
('', ''),
('draft', 'Draft'),
('requested', 'Requested'),
('commanded', 'Commanded'),
('in_preparation', 'In Preparation'),
('dispatched', 'Dispatched'),
('delivered', 'Delivered'),
('rejected', 'Rejected'),
('cancelled', 'Cancelled'),
], 'Order Status')
order_status = fields.Selection(OPTIONS_STATUS, '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')
order_status_time = fields.Many2One('sale.order_status.time', string='Times Order Status')
@classmethod
def __setup__(cls):
@ -323,6 +326,20 @@ class SaleForceDraft(Wizard):
return super(SaleForceDraft, self).transition_force_draft()
class OrderStatusTime(ModelSQL, ModelView):
"Sale Order Status Time"
__name__ = 'sale.order_status.time'
_rec_name = 'sale'
sale = fields.Many2One('sale.sale', 'Sale', ondelete='CASCADE')
requested = fields.DateTime('Requested')
commanded = fields.DateTime('commanded')
dispatched = fields.DateTime('Dispatched')
delivered = fields.DateTime('Delivered')
rejected = fields.DateTime('Rejected')
cancelled = fields.DateTime('Cancelled')
class SaleLine(metaclass=PoolMeta):
__name__ = 'sale.line'
production = fields.Many2One('production', 'Production')

View File

@ -1,5 +1,5 @@
[tryton]
version=6.0.3
version=6.0.4
depends:
ir
sale

View File

@ -9,4 +9,9 @@ copyright notices and license terms. -->
<field name="production_moves" colspan="4"/>
</page>
</xpath>
<xpath expr="/form/notebook/page[@id='other']/field[@name='shipment_method']"
position="after">
<label name="order_status_time"/>
<field name="order_status_time"/>
</xpath>
</data>