mirror of
https://github.com/NaN-tic/trytond-systemlogics_modula.git
synced 2023-12-14 04:32:53 +01:00
IMP ARTICOLI when create/write product/codes
This commit is contained in:
parent
6a688229be
commit
2a2c059756
|
@ -11,6 +11,7 @@ def register():
|
|||
Pool.register(
|
||||
SystemLogicsModula,
|
||||
Location,
|
||||
Product,
|
||||
ProductCode,
|
||||
ShipmentOut,
|
||||
ShipmentInternal,
|
||||
|
|
71
product.py
71
product.py
|
@ -3,22 +3,73 @@
|
|||
#the full copyright notices and license terms.
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
__all__ = ['ProductCode']
|
||||
__all__ = ['Product', 'ProductCode']
|
||||
__metaclass__ = PoolMeta
|
||||
_TYPE_BARCODES = ['EAN13']
|
||||
|
||||
|
||||
class Product:
|
||||
__name__ = 'product.product'
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
SystemLogicsModula = Pool().get('systemlogics.modula')
|
||||
|
||||
products = super(Product, cls).create(vlist)
|
||||
|
||||
systemlogics_products = []
|
||||
for product in products:
|
||||
if product.code and not product.codes:
|
||||
systemlogics_products.append(product)
|
||||
if systemlogics_products:
|
||||
SystemLogicsModula.imp_articoli(systemlogics_products)
|
||||
return products
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
SystemLogicsModula = Pool().get('systemlogics.modula')
|
||||
|
||||
super(Product, cls).write(*args)
|
||||
print "product write"
|
||||
systemlogics_products = []
|
||||
actions = iter(args)
|
||||
for products, values in zip(actions, actions):
|
||||
if 'code' in values and not values.get('codes'):
|
||||
systemlogics_products = products
|
||||
|
||||
if systemlogics_products:
|
||||
SystemLogicsModula.imp_articoli(systemlogics_products)
|
||||
|
||||
|
||||
class ProductCode:
|
||||
__name__ = 'product.code'
|
||||
|
||||
@classmethod
|
||||
def validate(cls, codes):
|
||||
super(ProductCode, cls).validate(codes)
|
||||
for code in codes:
|
||||
code.systemlogics_modula()
|
||||
def create(cls, vlist):
|
||||
pool = Pool()
|
||||
SystemLogicsModula = pool.get('systemlogics.modula')
|
||||
Product = pool.get('product.product')
|
||||
|
||||
def systemlogics_modula(self):
|
||||
SystemLogicsModula = Pool().get('systemlogics.modula')
|
||||
codes = super(ProductCode, cls).create(vlist)
|
||||
|
||||
if self.barcode in _TYPE_BARCODES and self.number:
|
||||
SystemLogicsModula.imp_articoli([self.product])
|
||||
vlist = [v.copy() for v in vlist]
|
||||
systemlogics_products = set()
|
||||
for values in vlist:
|
||||
systemlogics_products.add(values.get('product'))
|
||||
if systemlogics_products:
|
||||
products = Product.browse(list(systemlogics_products))
|
||||
SystemLogicsModula.imp_articoli(products)
|
||||
return codes
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
pool = Pool()
|
||||
SystemLogicsModula = pool.get('systemlogics.modula')
|
||||
Product = pool.get('product.product')
|
||||
|
||||
super(ProductCode, cls).write(*args)
|
||||
|
||||
codes = sum(args[::2], [])
|
||||
systemlogics_products = set(c.product for c in codes)
|
||||
if systemlogics_products:
|
||||
products = Product.browse(list(systemlogics_products))
|
||||
SystemLogicsModula.imp_articoli(products)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<SYSTORE_ARTICOLI xmlns:py="http://genshi.edgewall.org/">
|
||||
<IMP_ARTICOLI>
|
||||
<ART_ARTICOLO>${product.code_ean13}</ART_ARTICOLO>
|
||||
<ART_ARTICOLO>${product.code}</ART_ARTICOLO>
|
||||
<ART_DES>${product.rec_name[:100]}</ART_DES>
|
||||
<ART_UMI>${product.default_uom.symbol}</ART_UMI>
|
||||
<ART_PMU></ART_PMU>
|
||||
|
@ -9,7 +9,9 @@
|
|||
<ART_TIPOGESTART></ART_TIPOGESTART>
|
||||
<ART_FIFOP></ART_FIFOP>
|
||||
<ART_FIFOV></ART_FIFOV>
|
||||
<ART_NOTE></ART_NOTE>
|
||||
<ART_NOTE>
|
||||
${(code.number+'\n ' for code in product.codes)}
|
||||
</ART_NOTE>
|
||||
<ART_CLAMOV></ART_CLAMOV>
|
||||
</IMP_ARTICOLI>
|
||||
</SYSTORE_ARTICOLI>
|
||||
|
|
Loading…
Reference in a new issue