Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
d4c23446 by Maxime Richez at 2023-06-07T15:37:17+02:00
Disable unaccented search for inventory number
- - - - -
0b7f2304 by Maxime Richez at 2023-06-09T09:15:31+02:00
Add location and date to inventory name
Closes #12188
- - - - -
3 changed files:
- modules/stock/CHANGELOG
- modules/stock/inventory.py
- modules/stock/tests/scenario_stock_inventory.rst
Changes:
=====================================
modules/stock/CHANGELOG
=====================================
@@ -1,3 +1,4 @@
+* Add location and date to inventory name
Version 6.8.0 - 2023-05-01
--------------------------
=====================================
modules/stock/inventory.py
=====================================
@@ -8,7 +8,7 @@
from trytond.model.exceptions import AccessError
from trytond.pool import Pool
from trytond.pyson import Bool, Eval, If
-from trytond.tools import grouped_slice
+from trytond.tools import grouped_slice, is_full_text, lstrip_wildcard
from trytond.transaction import Transaction
from trytond.wizard import Button, StateTransition, StateView, Wizard
@@ -65,6 +65,7 @@
@classmethod
def __setup__(cls):
+ cls.number.search_unaccented = False
super(Inventory, cls).__setup__()
t = cls.__table__()
cls._sql_indexes.add(
@@ -122,6 +123,28 @@
def default_company():
return Transaction().context.get('company')
+ def get_rec_name(self, name):
+ pool = Pool()
+ Lang = pool.get('ir.lang')
+ lang = Lang.get()
+ date = lang.strftime(self.date)
+ return f"[{self.number}] {self.location.rec_name} @ {date}"
+
+ @classmethod
+ def search_rec_name(cls, name, clause):
+ _, operator, operand, *extra = clause
+ if operator.startswith('!') or operator.startswith('not '):
+ bool_op = 'AND'
+ else:
+ bool_op = 'OR'
+ number_value = operand
+ if operator.endswith('like') and is_full_text(operand):
+ number_value = lstrip_wildcard(operand)
+ return [bool_op,
+ ('number', operator, number_value, *extra),
+ ('location.rec_name', operator, operand, *extra),
+ ]
+
@classmethod
def view_attributes(cls):
return super().view_attributes() + [
=====================================
modules/stock/tests/scenario_stock_inventory.rst
=====================================
@@ -245,3 +245,14 @@
>>> inventory.click('complete_lines')
>>> len(inventory.lines)
0
+
+Create an inventory and check rec_name::
+
+ >>> Inventory = Model.get('stock.inventory')
+ >>> inventory = Inventory()
+ >>> inventory.date = dt.date(2023, 1, 31)
+ >>> inventory.location = storage_loc
+ >>> inventory.empty_quantity = 'keep'
+ >>> inventory.save()
+ >>> inventory.rec_name
+ '[6] Storage Zone @ 01/31/2023'
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/compare/6300c81867fd9969296f8e1509d21eec62f9079e...0b7f2304e2071e8671f08d0c259d7d58abeeb553
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/compare/6300c81867fd9969296f8e1509d21eec62f9079e...0b7f2304e2071e8671f08d0c259d7d58abeeb553
You're receiving this email because of your account on foss.heptapod.net.