added migration for vvow_* einweisungs fields in res.partner
This commit is contained in:
parent
0454aebc95
commit
95f3046196
|
|
@ -158,6 +158,57 @@ class ResPartner(models.Model):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def migrate_machine_access_from_old_fields(self):
|
||||||
|
"""
|
||||||
|
Migriert alte vvow_* Boolean-Felder in strukturierte ows.machine.access Einträge.
|
||||||
|
"""
|
||||||
|
mapping = [
|
||||||
|
# (altes Feld, machine.code)
|
||||||
|
('vvow_holz_sander', 'bandschleifer'),
|
||||||
|
('vvow_holz_felder_bandsaw', 'bandsaege_holz'),
|
||||||
|
('vvow_holz_felder_jointer', 'dickenhobel'),
|
||||||
|
('vvow_holz_felder_mill', 'felder_fraese'),
|
||||||
|
('vvow_holz_felder_tablesaw', 'formatkreissaege'),
|
||||||
|
('vvow_holz_mill', 'tischfraese'),
|
||||||
|
('vvow_holz_lathe', 'drechselbank'),
|
||||||
|
('vvow_holz_domino', 'festool_domino'),
|
||||||
|
('vvow_holz_duoduebler', 'maffel_duo'),
|
||||||
|
('vvow_holz_lamello', 'lamello_zeta_p2'),
|
||||||
|
('vvow_fablab_laser_sabko', 'sabako_laser'),
|
||||||
|
('vvow_fablab_3dprint_delta', '3d_delta'),
|
||||||
|
('vvow_fablab_3dprint_prusa', 'prusa'),
|
||||||
|
('vvow_fablab_3dprint_prusa_mmu', 'prusa_mmu'),
|
||||||
|
('vvow_fablab_cnc_beamicon', 'cnc_beamicon'),
|
||||||
|
('vvow_metall_welding_mig', 'mig_mag'),
|
||||||
|
('vvow_metall_welding_wig', 'wig'),
|
||||||
|
('vvow_metall_welding_misc', 'schweissen_allgemein'),
|
||||||
|
('vvow_metall_lathe', 'drehbank'),
|
||||||
|
('vvow_metall_bandsaw', 'bandsaege_metall'),
|
||||||
|
('vvow_metall_mill_fp2', 'fraese'),
|
||||||
|
('vvow_metall_bende', 'abkantbank'),
|
||||||
|
('vvow_metall_chop_saw', 'kreissaege_metall'),
|
||||||
|
]
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
for partner in self.search([]):
|
||||||
|
for field_name, machine_code in mapping:
|
||||||
|
if getattr(partner, field_name, False):
|
||||||
|
machine = self.env['ows.machine'].search([('code', '=', machine_code)], limit=1)
|
||||||
|
if machine:
|
||||||
|
already_exists = self.env['ows.machine.access'].search_count([
|
||||||
|
('partner_id', '=', partner.id),
|
||||||
|
('machine_id', '=', machine.id),
|
||||||
|
])
|
||||||
|
if not already_exists:
|
||||||
|
self.env['ows.machine.access'].create({
|
||||||
|
'partner_id': partner.id,
|
||||||
|
'machine_id': machine.id,
|
||||||
|
'date_granted': partner.create_date.date() if partner.create_date else date.today(),
|
||||||
|
})
|
||||||
|
count += 1
|
||||||
|
_logger.info(f"[OWS Migration] {count} Maschinenfreigaben aus alten Feldern erstellt.")
|
||||||
|
self.env.cr.commit()
|
||||||
|
|
||||||
class OwsUser(models.Model):
|
class OwsUser(models.Model):
|
||||||
_name = 'ows.user'
|
_name = 'ows.user'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user