Set WholeSaleUnit to altUnit if Extra1 is not set. Fix webUserName.
This commit is contained in:
parent
0af38e286e
commit
ee902ee733
3 changed files with 33 additions and 16 deletions
|
|
@ -97,8 +97,8 @@ class Article(RawBaseModel):
|
||||||
'Edit': 'ArticleLongSpec',
|
'Edit': 'ArticleLongSpec',
|
||||||
'LagSaldoArtikel': 'UnitBalance',
|
'LagSaldoArtikel': 'UnitBalance',
|
||||||
'EnhetsKod': 'Unit',
|
'EnhetsKod': 'Unit',
|
||||||
'ArtListPris': 'UnitListPrice',
|
# 'Extra1': 'WholeSaleUnit',
|
||||||
'Extra1': 'WholeSaleUnit'}
|
'ArtListPris': 'UnitListPrice'}
|
||||||
__to_dict_only__ = (
|
__to_dict_only__ = (
|
||||||
'ArtNr',
|
'ArtNr',
|
||||||
'ArtBeskr',
|
'ArtBeskr',
|
||||||
|
|
@ -114,7 +114,8 @@ class Article(RawBaseModel):
|
||||||
'ArtListPris',
|
'ArtListPris',
|
||||||
'PictureFileName',
|
'PictureFileName',
|
||||||
'UnitListPrice',
|
'UnitListPrice',
|
||||||
'Extra1',
|
# 'Extra1',
|
||||||
|
'WholeSaleUnit',
|
||||||
'ListPrice',
|
'ListPrice',
|
||||||
'Balance')
|
'Balance')
|
||||||
|
|
||||||
|
|
@ -131,19 +132,32 @@ class Article(RawBaseModel):
|
||||||
|
|
||||||
ArticleUnit = relationship(ArticleUnit)
|
ArticleUnit = relationship(ArticleUnit)
|
||||||
|
|
||||||
|
def _get_standard_alt_unit(self):
|
||||||
|
for unit in self.ArticleUnit:
|
||||||
|
if unit.AltEnhetOrderStd == "1":
|
||||||
|
return unit
|
||||||
|
|
||||||
def get_unit_conv(self):
|
def get_unit_conv(self):
|
||||||
if self.ArtFsgForp:
|
if self.ArtFsgForp:
|
||||||
return self.ArtFsgForp
|
return self.ArtFsgForp
|
||||||
|
|
||||||
for unit in self.ArticleUnit:
|
unit = self._get_standard_alt_unit()
|
||||||
if unit.AltEnhetOrderStd == "1":
|
if unit and unit.AltEnhetOmrFaktor:
|
||||||
if unit.AltEnhetOmrFaktor:
|
return unit.AltEnhetOmrFaktor
|
||||||
return unit.AltEnhetOmrFaktor
|
else:
|
||||||
else:
|
return unit.ArticleAlternativeUnit.AltEnhetOmrFaktor
|
||||||
return unit.ArticleAlternativeUnit.AltEnhetOmrFaktor
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@hybrid_property
|
||||||
|
def WholeSaleUnit(self):
|
||||||
|
if self.Extra1:
|
||||||
|
return self.Extra1
|
||||||
|
|
||||||
|
unit = self._get_standard_alt_unit()
|
||||||
|
if unit and not self.ArtFsgForp:
|
||||||
|
return unit.ArticleAlternativeUnit.AltEnhetBeskr
|
||||||
|
|
||||||
@hybrid_property
|
@hybrid_property
|
||||||
def ListPrice(self):
|
def ListPrice(self):
|
||||||
try:
|
try:
|
||||||
|
|
@ -330,12 +344,13 @@ class Order(RawBaseModel):
|
||||||
self['OrderNr'], invoicing_possible = OrderHead(self['FtgNr'], webusername).callproc()
|
self['OrderNr'], invoicing_possible = OrderHead(self['FtgNr'], webusername).callproc()
|
||||||
return self, invoicing_possible
|
return self, invoicing_possible
|
||||||
|
|
||||||
def save(self, invoiced=False):
|
def save(self, invoiced=False, webusername=None):
|
||||||
payment_method = 'invoice'
|
payment_method = 'invoice'
|
||||||
if not invoiced:
|
if not invoiced:
|
||||||
payment_method = 'card'
|
payment_method = 'card'
|
||||||
PlaceOrder(
|
PlaceOrder(
|
||||||
self['FtgNr'], self['OrderNr'], payment_method, data=self.to_dict()).callproc()
|
self['FtgNr'], self['OrderNr'], webusername,
|
||||||
|
payment_method, data=self.to_dict()).callproc()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,6 @@ class OrderHead(StoredProcedure):
|
||||||
# self['c_Saljare'] = None # 600 # From API profile, or default
|
# self['c_Saljare'] = None # 600 # From API profile, or default
|
||||||
|
|
||||||
# Unique ID added to 'kpw' when invoicing is allowed.
|
# Unique ID added to 'kpw' when invoicing is allowed.
|
||||||
print(web_user_name)
|
|
||||||
self['c_webUserName'] = web_user_name
|
self['c_webUserName'] = web_user_name
|
||||||
|
|
||||||
# self['LangID'] = 0 # Default to Swedish
|
# self['LangID'] = 0 # Default to Swedish
|
||||||
|
|
@ -141,7 +140,7 @@ class OrderRow(StoredProcedure):
|
||||||
AltEnhetKod logic needs to have been added to the procedure"""
|
AltEnhetKod logic needs to have been added to the procedure"""
|
||||||
|
|
||||||
def __init__(self, company_no, order_no, item_no,
|
def __init__(self, company_no, order_no, item_no,
|
||||||
qty=None, qty_alt_unit=None, alt_unit='', pers_sign='biz'):
|
qty=None, qty_alt_unit=None, alt_unit=None, pers_sign='biz'):
|
||||||
super(OrderRow, self).__init__('Jeeves_Esales_AddOrderRow')
|
super(OrderRow, self).__init__('Jeeves_Esales_AddOrderRow')
|
||||||
|
|
||||||
self['c_CompanyNo'] = str(company_no)
|
self['c_CompanyNo'] = str(company_no)
|
||||||
|
|
@ -149,7 +148,7 @@ class OrderRow(StoredProcedure):
|
||||||
self['c_ItemNo'] = str(item_no)
|
self['c_ItemNo'] = str(item_no)
|
||||||
self['c_Qty'] = float(qty) if qty else None
|
self['c_Qty'] = float(qty) if qty else None
|
||||||
self['c_QtyAltEnh'] = float(qty_alt_unit) if qty_alt_unit else None
|
self['c_QtyAltEnh'] = float(qty_alt_unit) if qty_alt_unit else None
|
||||||
self['c_AltEnhetKod'] = str(alt_unit)
|
self['c_AltEnhetKod'] = str(alt_unit) if alt_unit else None
|
||||||
self['c_PersSign'] = str(pers_sign)
|
self['c_PersSign'] = str(pers_sign)
|
||||||
|
|
||||||
# Used to set date for delivery (c_OrdBegLevDat) and (c_OrdBerLevDat)
|
# Used to set date for delivery (c_OrdBegLevDat) and (c_OrdBerLevDat)
|
||||||
|
|
@ -194,7 +193,7 @@ class PlaceOrder(StoredProcedure):
|
||||||
"""Mapping for the Jeeves_Esales_PlaceOrder stored procedure parameters
|
"""Mapping for the Jeeves_Esales_PlaceOrder stored procedure parameters
|
||||||
webapp031 and WEBAPP003 determines default order status"""
|
webapp031 and WEBAPP003 determines default order status"""
|
||||||
|
|
||||||
def __init__(self, company_no, order_no, payment_method='card', data={}):
|
def __init__(self, company_no, order_no, web_user_name=None, payment_method='card', data={}):
|
||||||
super(PlaceOrder, self).__init__('Jeeves_Esales_PlaceOrder')
|
super(PlaceOrder, self).__init__('Jeeves_Esales_PlaceOrder')
|
||||||
|
|
||||||
self['c_CompanyNo'] = str(company_no)
|
self['c_CompanyNo'] = str(company_no)
|
||||||
|
|
@ -219,6 +218,9 @@ class PlaceOrder(StoredProcedure):
|
||||||
# 1 = card, else invoice. Card requires manual update.
|
# 1 = card, else invoice. Card requires manual update.
|
||||||
self['c_PaymentType'] = '1' if payment_method is 'card' else '0'
|
self['c_PaymentType'] = '1' if payment_method is 'card' else '0'
|
||||||
|
|
||||||
|
# Unique ID added to 'kpw' when invoicing is allowed.
|
||||||
|
self['c_webUserName'] = web_user_name
|
||||||
|
|
||||||
self['c_LevSattKod'] = 2 # 2 = Schenker, 4 = Collect
|
self['c_LevSattKod'] = 2 # 2 = Schenker, 4 = Collect
|
||||||
self['c_orderStatus'] = None # Override orderStatusCode when using invoicing
|
self['c_orderStatus'] = None # Override orderStatusCode when using invoicing
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class Order():
|
||||||
|
|
||||||
# Save the information in the order object
|
# Save the information in the order object
|
||||||
# Boolean argument deceides if order has contact person, and should be set 'registered'
|
# Boolean argument deceides if order has contact person, and should be set 'registered'
|
||||||
order.save(invoice_possible)
|
order.save(invoice_possible, web_user_name)
|
||||||
|
|
||||||
return order
|
return order
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue