"Sequence and tree editable migration to 6.0 [SKIP CI]."
This commit is contained in:
parent
8b81ff77d4
commit
e07003414c
|
@ -2,6 +2,7 @@
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
from trytond.model import ModelSQL, ModelSingleton, ModelView, fields
|
from trytond.model import ModelSQL, ModelSingleton, ModelView, fields
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
|
from trytond.pyson import Id
|
||||||
from trytond.modules.company.model import (
|
from trytond.modules.company.model import (
|
||||||
CompanyMultiValueMixin, CompanyValueMixin)
|
CompanyMultiValueMixin, CompanyValueMixin)
|
||||||
|
|
||||||
|
@ -15,7 +16,10 @@ class Configuration(
|
||||||
|
|
||||||
edocument_sequence = fields.MultiValue(
|
edocument_sequence = fields.MultiValue(
|
||||||
fields.Many2One('ir.sequence', 'Electronic Document Sequence',
|
fields.Many2One('ir.sequence', 'Electronic Document Sequence',
|
||||||
required=True))
|
required=True, domain=[
|
||||||
|
('sequence_type', '=', Id('edocument_edifact',
|
||||||
|
'sequence_type_edocument'))
|
||||||
|
]))
|
||||||
export_path = fields.Char('Export Path')
|
export_path = fields.Char('Export Path')
|
||||||
import_path = fields.Char('Import Path')
|
import_path = fields.Char('Import Path')
|
||||||
error_path = fields.Char('Error Path')
|
error_path = fields.Char('Error Path')
|
||||||
|
@ -33,7 +37,11 @@ class ConfigurationSequence(ModelSQL, CompanyValueMixin):
|
||||||
__name__ = 'edocument.configuration.sequence'
|
__name__ = 'edocument.configuration.sequence'
|
||||||
|
|
||||||
edocument_sequence = fields.Many2One(
|
edocument_sequence = fields.Many2One(
|
||||||
'ir.sequence', 'Electronic Document Sequence', required=True)
|
'ir.sequence', 'Electronic Document Sequence', required=True,
|
||||||
|
domain=[
|
||||||
|
('sequence_type', '=', Id('edocument_edifact',
|
||||||
|
'sequence_type_edocument'))
|
||||||
|
])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_edocument_sequence(cls):
|
def default_edocument_sequence(cls):
|
||||||
|
|
13
edocument.py
13
edocument.py
|
@ -4,6 +4,7 @@ from trytond.model import ModelSQL, ModelView, fields, Exclude
|
||||||
from sql.conditionals import Coalesce
|
from sql.conditionals import Coalesce
|
||||||
from sql.operators import Equal as SqlEqual
|
from sql.operators import Equal as SqlEqual
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
|
from trytond.transaction import Transaction
|
||||||
from io import open
|
from io import open
|
||||||
import oyaml as yaml
|
import oyaml as yaml
|
||||||
import os
|
import os
|
||||||
|
@ -16,7 +17,6 @@ KNOWN_EXTENSIONS = ['.txt', '.edi', '.pla']
|
||||||
class EdocumentTemplate(ModelView, ModelSQL):
|
class EdocumentTemplate(ModelView, ModelSQL):
|
||||||
"""Electronic Document Template"""
|
"""Electronic Document Template"""
|
||||||
__name__ = 'edocument.template'
|
__name__ = 'edocument.template'
|
||||||
rec_name = fields.Function(fields.Char('Record Name'), 'get_rec_name')
|
|
||||||
|
|
||||||
message_type = fields.Selection([('DESADV', 'DESADV'),
|
message_type = fields.Selection([('DESADV', 'DESADV'),
|
||||||
('INVOIC', 'INVOIC')], 'Document', required=True)
|
('INVOIC', 'INVOIC')], 'Document', required=True)
|
||||||
|
@ -49,7 +49,6 @@ class EdocumentTemplate(ModelView, ModelSQL):
|
||||||
class EdocumentMessage(ModelView, ModelSQL):
|
class EdocumentMessage(ModelView, ModelSQL):
|
||||||
"""EDIFACT message"""
|
"""EDIFACT message"""
|
||||||
__name__ = 'edocument.message'
|
__name__ = 'edocument.message'
|
||||||
rec_name = fields.Function(fields.Char('Record Name'), 'get_rec_name')
|
|
||||||
|
|
||||||
code = fields.Char('Code')
|
code = fields.Char('Code')
|
||||||
message = fields.Text('Message')
|
message = fields.Text('Message')
|
||||||
|
@ -77,17 +76,19 @@ class EdocumentMessage(ModelView, ModelSQL):
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Configuration = pool.get('edocument.configuration')
|
Configuration = pool.get('edocument.configuration')
|
||||||
Sequence = Pool().get('ir.sequence')
|
|
||||||
config = Configuration(1)
|
config = Configuration(1)
|
||||||
|
|
||||||
|
default_company = Transaction().context.get('company', None)
|
||||||
vlist = [x.copy() for x in vlist]
|
vlist = [x.copy() for x in vlist]
|
||||||
for values in vlist:
|
for values in vlist:
|
||||||
if config.edocument_sequence:
|
if config.edocument_sequence:
|
||||||
values['code'] = Sequence.get_id(config.edocument_sequence.id)
|
values['code'] = config.get_multivalue(
|
||||||
|
'edocument_sequence',
|
||||||
|
company=values.get('company', default_company)).get()
|
||||||
return super(EdocumentMessage, cls).create(vlist)
|
return super(EdocumentMessage, cls).create(vlist)
|
||||||
|
|
||||||
|
|
||||||
class EdocumentMixin():
|
class EdocumentMixin(object):
|
||||||
messages = fields.One2Many('edocument.message', 'origin', 'Message')
|
messages = fields.One2Many('edocument.message', 'origin', 'Message')
|
||||||
edocument_processed = fields.Function(
|
edocument_processed = fields.Function(
|
||||||
fields.Boolean('Processed'), 'get_edocument_processed',
|
fields.Boolean('Processed'), 'get_edocument_processed',
|
||||||
|
@ -199,7 +200,7 @@ class EdocumentImportMixin(EdocumentMixin):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
class EdocumentFileManager():
|
class EdocumentFileManager(object):
|
||||||
''' Imports EDI objects from a folder '''
|
''' Imports EDI objects from a folder '''
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<data>
|
<data>
|
||||||
<record model="ir.sequence.type" id="sequence_type_edocument">
|
<record model="ir.sequence.type" id="sequence_type_edocument">
|
||||||
<field name="name">Electronic Document</field>
|
<field name="name">Electronic Document</field>
|
||||||
<field name="code">edocument.message</field>
|
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence.type-res.group"
|
<record model="ir.sequence.type-res.group"
|
||||||
id="sequence_type_edocument_group_admin">
|
id="sequence_type_edocument_group_admin">
|
||||||
|
@ -14,7 +13,7 @@
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence" id="sequence_edocument">
|
<record model="ir.sequence" id="sequence_edocument">
|
||||||
<field name="name">Electronic Document sequence</field>
|
<field name="name">Electronic Document sequence</field>
|
||||||
<field name="code">edocument.message</field>
|
<field name="sequence_type" ref="sequence_type_edocument"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Edocument Template -->
|
<!-- Edocument Template -->
|
||||||
|
|
11
stock.py
11
stock.py
|
@ -2,6 +2,7 @@
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
from trytond.model import fields, ModelSQL
|
from trytond.model import fields, ModelSQL
|
||||||
from trytond.pool import PoolMeta, Pool
|
from trytond.pool import PoolMeta, Pool
|
||||||
|
from trytond.pyson import Id
|
||||||
from trytond.tools.multivalue import migrate_property
|
from trytond.tools.multivalue import migrate_property
|
||||||
from trytond.modules.company.model import CompanyValueMixin
|
from trytond.modules.company.model import CompanyValueMixin
|
||||||
from trytond.modules.product_ean.tools import get_control_digit
|
from trytond.modules.product_ean.tools import get_control_digit
|
||||||
|
@ -16,7 +17,10 @@ class Configuration(metaclass=PoolMeta):
|
||||||
|
|
||||||
edocument_sequence = fields.MultiValue(
|
edocument_sequence = fields.MultiValue(
|
||||||
fields.Many2One('ir.sequence', 'Electronic Document Sequence',
|
fields.Many2One('ir.sequence', 'Electronic Document Sequence',
|
||||||
required=True))
|
required=True, domain=[
|
||||||
|
('sequence_type', '=', Id('edocument_edifact',
|
||||||
|
'sequence_type_edocument'))
|
||||||
|
]))
|
||||||
EDI_output_path = fields.MultiValue(fields.Char('EDI Output Path'))
|
EDI_output_path = fields.MultiValue(fields.Char('EDI Output Path'))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -38,7 +42,10 @@ class ConfigurationSequence(metaclass=PoolMeta):
|
||||||
__name__ = 'stock.configuration.sequence'
|
__name__ = 'stock.configuration.sequence'
|
||||||
|
|
||||||
edocument_sequence = fields.Many2One('ir.sequence',
|
edocument_sequence = fields.Many2One('ir.sequence',
|
||||||
'Electronic Document Sequence', required=True)
|
'Electronic Document Sequence', required=True, domain=[
|
||||||
|
('sequence_type', '=', Id('edocument_edifact',
|
||||||
|
'sequence_type_edocument'))
|
||||||
|
])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __register__(cls, module_name):
|
def __register__(cls, module_name):
|
||||||
|
|
Loading…
Reference in New Issue