Truncate "blue line" text if necessary when updating CORE
This commit is contained in:
parent
e332872f46
commit
f07c767826
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2023 Lance Edgar
|
# Copyright © 2010-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -163,6 +163,30 @@ class CustomerClassicImporter(ToCore):
|
||||||
model_class = corepos.CustomerClassic
|
model_class = corepos.CustomerClassic
|
||||||
key = 'id'
|
key = 'id'
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
super().setup()
|
||||||
|
self.common_setup()
|
||||||
|
|
||||||
|
def datasync_setup(self):
|
||||||
|
super().datasync_setup()
|
||||||
|
self.common_setup()
|
||||||
|
|
||||||
|
def common_setup(self):
|
||||||
|
if 'blue_line' in self.fields:
|
||||||
|
self.maxlen_blue_line = self.app.maxlen(corepos.CustomerClassic.blue_line)
|
||||||
|
|
||||||
|
def update_object(self, customer, data, local_data=None):
|
||||||
|
|
||||||
|
if 'blue_line' in self.fields:
|
||||||
|
blue_line = data['blue_line']
|
||||||
|
if blue_line and len(blue_line) > self.maxlen_blue_line:
|
||||||
|
log.warning("blue_line value is %s chars but will be truncated to %s: %s",
|
||||||
|
len(blue_line), self.maxlen_blue_line, blue_line)
|
||||||
|
data['blue_line'] = blue_line[:self.maxlen_blue_line]
|
||||||
|
|
||||||
|
customer = super().update_object(customer, data, local_data=local_data)
|
||||||
|
return customer
|
||||||
|
|
||||||
|
|
||||||
class MemberTypeImporter(ToCore):
|
class MemberTypeImporter(ToCore):
|
||||||
model_class = corepos.MemberType
|
model_class = corepos.MemberType
|
||||||
|
|
Loading…
Reference in a new issue