Group numbering of account assets

This commit is contained in:
Cédric Krier committed 2024-08-25 12:15:39 +02:00
1 parent 7bafe98a0c
commit 46b6c17595
1 file changed
+9 -5
+9 -5
View File
@@ -632,11 +632,15 @@ class Asset(Workflow, ModelSQL, ModelView):
Config = pool.get('account.configuration')
config = Config(1)
for asset in assets:
if asset.number:
continue
asset.number = config.get_multivalue(
'asset_sequence', company=asset.company.id).get()
for company, c_assets in groupby(assets, key=lambda a: a.company):
c_assets = [a for a in c_assets if not a.number]
if c_assets:
sequence = config.get_multivalue(
'asset_sequence', company=company.id)
for asset, number in zip(
c_assets, sequence.get_many(len(c_assets))):
asset.number = number
cls.save(assets)
@classmethod