Skip to content
Snippets Groups Projects
Commit 5bd2ee43 authored by Cédric Krier's avatar Cédric Krier :atom:
Browse files

Use MultiValue for product lead time

and remove CompanyValueMixin for default lead time.

issue11428
review403411002
parent bfdbf327
1 merge request!114Return an empty list when the treeview has no selection
* Use MultiValue for product lead time
* Remove CompanyValueMixin for default lead time
Version 6.4.0 - 2022-05-02
* Bug fixes (see mercurial logs for details)
* Add customer currency on party
......
......@@ -23,6 +23,7 @@
product.Configuration,
product.DefaultLeadTime,
product.Template,
product.ProductLeadTime,
product.Product,
product.SaleContext,
stock.ShipmentOut,
......
......@@ -2,8 +2,9 @@
# this repository contains the full copyright notices and license terms.
import datetime
from trytond.model import ModelSQL, ModelView, fields
from trytond.modules.company.model import CompanyValueMixin
from sql import Null
from trytond.model import ModelSQL, ModelView, ValueMixin, fields
from trytond.modules.currency.fields import Monetary
from trytond.modules.product import price_digits
from trytond.pool import Pool, PoolMeta
......@@ -26,7 +27,7 @@
return datetime.timedelta(0)
class DefaultLeadTime(ModelSQL, CompanyValueMixin):
class DefaultLeadTime(ModelSQL, ValueMixin):
"Product Default Lead Time"
__name__ = 'product.configuration.default_lead_time'
default_lead_time = fields.TimeDelta("Default Lead Time")
......@@ -44,14 +45,14 @@
domain=[
('category', '=', Eval('default_uom_category')),
])
lead_time = fields.TimeDelta(
"Lead Time",
states={
'invisible': ~Eval('salable', False),
},
help="The time from confirming the sales order to sending the "
"products.\n"
"If empty the default lead time from the configuration is used.")
lead_time = fields.MultiValue(fields.TimeDelta(
"Lead Time",
states={
'invisible': ~Eval('salable', False),
},
help="The time from confirming the sales order to sending the "
"products.\n"
"If empty the default lead time from the configuration is used."))
@classmethod
def __register__(cls, module_name):
......@@ -77,6 +78,13 @@
where=sql_table.id == id_))
table.drop_column('delivery_time')
@classmethod
def multivalue_model(cls, field):
pool = Pool()
if field == 'lead_time':
return pool.get('product.lead_time')
return super().multivalue_model(field)
@fields.depends('default_uom', 'sale_uom', 'salable')
def on_change_default_uom(self):
try:
......@@ -98,6 +106,34 @@
})]
class ProductLeadTime(ModelSQL, ValueMixin):
"Product Lead Time"
__name__ = 'product.lead_time'
template = fields.Many2One(
'product.template', "Template", ondelete='CASCADE', select=True)
lead_time = fields.TimeDelta("Lead Time")
@classmethod
def __register__(cls, module_name):
pool = Pool()
Template = pool.get('product.template')
template = Template.__table__()
table = cls.__table__()
super().__register__(module_name)
cursor = Transaction().connection.cursor()
template_h = Template.__table_handler__(module_name)
if template_h.column_exist('lead_time'):
cursor.execute(*table.insert(
columns=[table.template, table.lead_time],
values=template.select(
template.id, template.lead_time,
where=template.lead_time != Null)))
template_h.drop_column('lead_time')
class Product(metaclass=PoolMeta):
__name__ = 'product.product'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment