44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
# The COPYRIGHT file at the top level of
|
|
# this repository contains the full copyright notices and license terms.
|
|
from trytond.model import ModelSQL, ModelView, fields
|
|
from trytond.pool import PoolMeta
|
|
|
|
__all__ = ['Configuration', 'UnitLoad']
|
|
|
|
|
|
class Configuration:
|
|
__metaclass__ = PoolMeta
|
|
__name__ = 'stock.configuration'
|
|
edocument_sequence = fields.Property(
|
|
fields.Many2One('ir.sequence', 'Electronic Document Sequence'
|
|
, required=True))
|
|
EDI_output_path = fields.Property(fields.Char('EDI Output Path'))
|
|
|
|
|
|
class UnitLoad:
|
|
__metaclass__ = PoolMeta
|
|
__name__ = 'stock.unit_load'
|
|
|
|
def get_best_before(self):
|
|
return None
|
|
|
|
def get_sscc(self):
|
|
if self.shipment_out:
|
|
edi_codes = [identifier.code for identifier in filter(
|
|
lambda x: x.type == 'EDI_sender',
|
|
self.shipment_out.company.party.identifiers)]
|
|
edi_code = edi_codes[0][:6] if edi_codes else '000000'
|
|
code = '00' + edi_code + self.code[-9:].zfill(len(self.code[-9:])-9)
|
|
return code + str(self._sscc_control_digit(code))
|
|
return None
|
|
|
|
def get_grai(self):
|
|
return None
|
|
|
|
@staticmethod
|
|
def _sscc_control_digit(num):
|
|
nums = (int(c) for c in num)
|
|
multipliers = [3, 1]
|
|
return 10 - sum((digit * multipliers[index % 2]
|
|
for index, digit in enumerate(nums))) % 10
|