details:   https://code.tryton.org/tryton/commit/7fc7538b4125
branch:    default
user:      Cédric Krier <[email protected]>
date:      Sat Dec 20 10:23:56 2025 +0100
description:
        Remove required on before/after carrier column of incoterm

        We must rely only on the selection validation to require a value to 
permit to
        create new incoterm in incoterm module when carrier_carriage is already
        activated.

        Closes #14440
diffstat:

 doc/migration.rst                    |  12 ++++++++++++
 modules/carrier_carriage/incoterm.py |  13 +++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diffs (47 lines):

diff -r 04700b48b6b7 -r 7fc7538b4125 doc/migration.rst
--- a/doc/migration.rst Sat Dec 20 10:08:09 2025 +0100
+++ b/doc/migration.rst Sat Dec 20 10:23:56 2025 +0100
@@ -17,6 +17,18 @@
 7.8
 ---
 
+Before
+~~~~~~
+
+* If ``carrier_carriage`` module is activated, remove ``NOT NULL`` to
+  ``before_carrier`` and ``after_carrier``:
+
+  .. code-block:: SQL
+
+     ALTER TABLE "incoterm_incoterm" ALTER COLUMN "before_carrier" DROP NOT 
NULL;
+     ALTER TABLE "incoterm_incoterm" ALTER COLUMN "after_carrier" DROP NOT 
NULL;
+
+
 After
 ~~~~~
 
diff -r 04700b48b6b7 -r 7fc7538b4125 modules/carrier_carriage/incoterm.py
--- a/modules/carrier_carriage/incoterm.py      Sat Dec 20 10:08:09 2025 +0100
+++ b/modules/carrier_carriage/incoterm.py      Sat Dec 20 10:23:56 2025 +0100
@@ -11,10 +11,19 @@
     before_carrier = fields.Selection([
             ('buyer', "Buyer"),
             ('seller', "Seller"),
-            ], "Before Carrier", required=True,
+            ], "Before Carrier",
         help="Who contracts carriages before main carriage.")
     after_carrier = fields.Selection([
             ('buyer', "Buyer"),
             ('seller', "Seller"),
-            ], "After Carrier", required=True,
+            ], "After Carrier",
         help="Who contracts carriages after main carriage.")
+
+    @classmethod
+    def __register__(cls, module_name):
+        table_h = cls.__table_handler__(module_name)
+        super().__register__(module_name)
+        # Migration from 7.6: remove required on before/after_carrier
+        # to permit to create new incoterm in incoterm module
+        table_h.not_null_action('before_carrier', 'remove')
+        table_h.not_null_action('after_carrier', 'remove')

Reply via email to