changeset 3abc70403fb8 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=3abc70403fb8
description:
Enforce positive timedelta
issue11869
review421921004
diffstat:
configuration.py | 9 +++++++--
party.py | 18 ++++++++++++------
product.py | 9 +++++++--
3 files changed, 26 insertions(+), 10 deletions(-)
diffs (98 lines):
diff -r bd12890a446c -r 3abc70403fb8 configuration.py
--- a/configuration.py Mon Oct 31 17:07:15 2022 +0100
+++ b/configuration.py Thu Nov 24 19:16:51 2022 +0100
@@ -6,7 +6,7 @@
from trytond.modules.company.model import (
CompanyMultiValueMixin, CompanyValueMixin)
from trytond.pool import Pool
-from trytond.pyson import Eval, Id
+from trytond.pyson import Eval, Id, TimeDelta
from trytond.tools.multivalue import migrate_property
purchase_invoice_method = fields.Selection(
@@ -36,7 +36,12 @@
]))
purchase_invoice_method = fields.MultiValue(purchase_invoice_method)
get_purchase_invoice_method = get_purchase_methods('invoice_method')
- purchase_process_after = fields.TimeDelta("Process Purchase after",
+ purchase_process_after = fields.TimeDelta(
+ "Process Purchase after",
+ domain=['OR',
+ ('purchase_process_after', '=', None),
+ ('purchase_process_after', '>=', TimeDelta()),
+ ],
help="The grace period during which confirmed purchase "
"can still be reset to draft.\n"
"Applied only if a worker queue is activated.")
diff -r bd12890a446c -r 3abc70403fb8 party.py
--- a/party.py Mon Oct 31 17:07:15 2022 +0100
+++ b/party.py Thu Nov 24 19:16:51 2022 +0100
@@ -6,11 +6,20 @@
CompanyMultiValueMixin, CompanyValueMixin)
from trytond.modules.party.exceptions import EraseError
from trytond.pool import Pool, PoolMeta
-from trytond.pyson import Eval
+from trytond.pyson import Eval, TimeDelta
supplier_currency = fields.Many2One(
'currency.currency', "Supplier Currency",
help="Default currency for purchases from this party.")
+supplier_lead_time = fields.TimeDelta(
+ "Lead Time",
+ domain=['OR',
+ ('supplier_lead_time', '=', None),
+ ('supplier_lead_time', '>=', TimeDelta()),
+ ],
+ help="The time from confirming the purchase order to receiving "
+ "the goods from the party when used as a supplier.\n"
+ "Used if no lead time is set on the product supplier.")
class Party(CompanyMultiValueMixin, metaclass=PoolMeta):
@@ -20,10 +29,7 @@
" as customer."))
customer_codes = fields.One2Many(
'party.party.customer_code', 'party', "Customer Codes")
- supplier_lead_time = fields.MultiValue(fields.TimeDelta("Lead Time",
- help="The time from confirming the purchase order to receiving "
- "the goods from the party when used as a supplier.\n"
- "Used if no lead time is set on the product supplier."))
+ supplier_lead_time = fields.MultiValue(supplier_lead_time)
supplier_lead_times = fields.One2Many(
'party.party.supplier_lead_time', 'party', "Lead Times")
supplier_currency = fields.MultiValue(supplier_currency)
@@ -52,7 +58,7 @@
'company': Eval('company', -1),
},
depends={'company'})
- supplier_lead_time = fields.TimeDelta("Lead Time")
+ supplier_lead_time = supplier_lead_time
class PartySupplierCurrency(ModelSQL, ValueMixin):
diff -r bd12890a446c -r 3abc70403fb8 product.py
--- a/product.py Mon Oct 31 17:07:15 2022 +0100
+++ b/product.py Thu Nov 24 19:16:51 2022 +0100
@@ -12,7 +12,7 @@
from trytond.modules.currency.fields import Monetary
from trytond.modules.product import price_digits
from trytond.pool import Pool, PoolMeta
-from trytond.pyson import Bool, Eval, If
+from trytond.pyson import Bool, Eval, If, TimeDelta
from trytond.tools import is_full_text, lstrip_wildcard
from trytond.transaction import Transaction
@@ -285,7 +285,12 @@
company = fields.Many2One(
'company.company', "Company",
required=True, ondelete='CASCADE')
- lead_time = fields.TimeDelta('Lead Time',
+ lead_time = fields.TimeDelta(
+ "Lead Time",
+ domain=['OR',
+ ('lead_time', '=', None),
+ ('lead_time', '>=', TimeDelta()),
+ ],
help="The time from confirming the purchase order to receiving the "
"products.\n"
"If empty the lead time of the supplier is used.")