added template per party

This commit is contained in:
Marcos Sabater 2019-08-28 16:37:06 +02:00
parent 753cd40990
commit 22cb41f650
9 changed files with 210 additions and 19 deletions

View File

@ -1,6 +1,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.pool import Pool
from . import configuration
from . import edocument
from . import stock
from . import party
@ -10,11 +11,13 @@ from . import incoterm
def register():
Pool.register(
configuration.Configuration,
configuration.ConfigurationSequence,
edocument.EdocumentMessage,
edocument.EdocumentTemplate,
party.Party,
party.PartyIdentifier,
stock.Configuration,
stock.ConfigurationSequence,
stock.ConfigurationEDIOutputPath,
stock.UnitLoad,
incoterm.Rule,

43
configuration.py Normal file
View File

@ -0,0 +1,43 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from trytond.model import ModelSQL, ModelSingleton, ModelView, fields
from trytond.pool import Pool
from trytond.modules.company.model import (
CompanyMultiValueMixin, CompanyValueMixin)
__all__ = ['Configuration', 'ConfigurationSequence']
class Configuration(
ModelSingleton, ModelSQL, ModelView, CompanyMultiValueMixin):
"""Edocument Configuration"""
__name__ = 'edocument.configuration'
edocument_sequence = fields.MultiValue(
fields.Many2One('ir.sequence', 'Electronic Document Sequence',
required=True))
export_path = fields.Char('Export Path')
@classmethod
def multivalue_model(cls, field):
pool = Pool()
if field == 'edocument_sequence':
return pool.get('edocument.configuration.sequence')
return super(Configuration, cls).multivalue_model(field)
class ConfigurationSequence(ModelSQL, CompanyValueMixin):
"""Edocument Configuration Sequence"""
__name__ = 'edocument.configuration.sequence'
edocument_sequence = fields.Many2One(
'ir.sequence', 'Electronic Document Sequence', required=True)
@classmethod
def default_edocument_sequence(cls):
pool = Pool()
ModelData = pool.get('ir.model.data')
try:
return ModelData.get_id('edocument_edifact', 'sequence_edocument')
except KeyError:
return None

View File

@ -1,16 +1,43 @@
# 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.model import ModelSQL, ModelView, fields, Exclude
from sql.conditionals import Coalesce
from sql.operators import Equal as SqlEqual
from trytond.pool import Pool
from io import open
import oyaml as yaml
import os
__all__ = ['EdocumentMessage']
__all__ = ['EdocumentMessage', 'EdocumentTemplate']
KNOWN_EXTENSIONS = ['.txt', '.edi', '.pla']
class EdocumentTemplate(ModelView, ModelSQL):
"""Electronic Document Template"""
__name__ = 'edocument.template'
rec_name = fields.Function(fields.Char('Record Name'), 'get_rec_name')
message_type = fields.Selection([('DESADV', 'DESADV'),
('INVOIC', 'INVOIC')], 'Document', required=True)
party = fields.Many2One('party.party', 'Party')
template = fields.Text('Template')
@classmethod
def __setup__(cls):
super(EdocumentTemplate, cls).__setup__()
t = cls.__table__()
cls._sql_constraints = [
('document_party_exclude', Exclude(t,
(t.message_type, SqlEqual),
(Coalesce(t.party, -1), SqlEqual)),
'Combination of message type and party must be unique.')]
def get_rec_name(self, name):
return self.message_type + ' ' + self.party.name
class EdocumentMessage(ModelView, ModelSQL):
"""EDIFACT message"""
__name__ = 'edocument.message'
@ -23,7 +50,7 @@ class EdocumentMessage(ModelView, ModelSQL):
@classmethod
def create(cls, vlist):
pool = Pool()
Configuration = pool.get('stock.configuration')
Configuration = pool.get('edocument.configuration')
Sequence = Pool().get('ir.sequence')
config = Configuration(1)

View File

@ -16,5 +16,91 @@
<field name="name">Electronic Document sequence</field>
<field name="code">edocument.message</field>
</record>
<!-- Edocument Template -->
<record model="ir.ui.view" id="edocument_template_view_tree">
<field name="model">edocument.template</field>
<field name="type">tree</field>
<field name="name">edocument_template_tree</field>
</record>
<record model="ir.ui.view" id="edocument_template_view_form">
<field name="model">edocument.template</field>
<field name="type">form</field>
<field name="name">edocument_template_form</field>
</record>
<record model="ir.action.act_window" id="act_edocument_template_form">
<field name="name">Edocument Templates</field>
<field name="res_model">edocument.template</field>
</record>
<record model="ir.action.act_window.view" id="act_edocument_template_list_view">
<field name="sequence" eval="10"/>
<field name="view" ref="edocument_template_view_tree"/>
<field name="act_window" ref="act_edocument_template_form"/>
</record>
<record model="ir.action.act_window.view" id="act_edocument_template_form_view">
<field name="sequence" eval="20"/>
<field name="view" ref="edocument_template_view_form"/>
<field name="act_window" ref="act_edocument_template_form"/>
</record>
<record model="ir.model.access" id="access_edocument_template">
<field name="model" search="[('model', '=', 'edocument.template')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_edocument_template_admin">
<field name="model" search="[('model', '=', 'edocument.template')]"/>
<field name="group" ref="res.group_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<!-- Edocument Configuration -->
<record model="ir.ui.view" id="edocument_configuration_view_form">
<field name="model">edocument.configuration</field>
<field name="type">form</field>
<field name="name">configuration_form</field>
</record>
<record model="ir.action.act_window" id="act_edocument_configuration_form">
<field name="name">Edocument Configuration</field>
<field name="res_model">edocument.configuration</field>
</record>
<record model="ir.action.act_window.view" id="act_edocument_configuration_form_view">
<field name="sequence" eval="20"/>
<field name="view" ref="edocument_configuration_view_form"/>
<field name="act_window" ref="act_edocument_configuration_form"/>
</record>
<record model="ir.model.access" id="access_edocument_configuration">
<field name="model" search="[('model', '=', 'edocument.configuration')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_edocument_configuration_admin">
<field name="model" search="[('model', '=', 'edocument.configuration')]"/>
<field name="group" ref="res.group_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<menuitem parent="ir.menu_administration" sequence="110"
name="Edocument" id="menu_edocument" icon="tryton-folder"/>
<menuitem parent="menu_edocument" sequence="0"
name="Configuration" id="menu_configuration" icon="tryton-settings"/>
<menuitem parent="menu_configuration" sequence="10" id="menu_edocument_configuration"
action="act_edocument_configuration_form"/>
<menuitem parent="menu_edocument" sequence="10" id="menu_edocument_template"
action="act_edocument_template_form"/>
</data>
</tryton>

View File

@ -9,11 +9,11 @@ __all__ = ['Party', 'PartyIdentifier']
class Party(metaclass=PoolMeta):
__name__ = 'party.party'
edi_template_path = fields.Char('Template Path')
edi_add_header = fields.Boolean('Add Header')
edi_release_number = fields.Selection([
(None, ' '),
('96A', '96A'),
('93A', '93A'),
('01B', '01B'),
], 'Release Number')
edi_assigned_code = fields.Selection([
@ -37,8 +37,8 @@ class PartyIdentifier(metaclass=PoolMeta):
@classmethod
def __setup__(cls):
super(PartyIdentifier, cls).__setup__()
cls.type.selection.extend(
[('EDI_sender', 'EDI Sender'),
cls.type.selection.extend([
('EDI_sender', 'EDI Sender'),
('EDI_receiver', 'EDI Receiver'),
('EDI_supplier', 'EDI Supplier')])
('EDI_supplier', 'EDI Supplier'),
('EDI_payer', 'EDI Payer')])

View File

@ -11,7 +11,9 @@ from configparser import ConfigParser
MODULE2PREFIX = {
'incoterm': 'datalife',
'stock_unit_load': 'datalife',
'product_ean': 'datalife'
'product_ean': 'datalife',
'product_cross_reference': 'datalife',
'party_edi': 'nantic'
}
@ -34,7 +36,7 @@ def get_require_version(name):
config = ConfigParser()
config.readfp(open('tryton.cfg'))
config.read_file(open('tryton.cfg'))
info = dict(config.items('tryton'))
for key in ('depends', 'extras_depend', 'xml'):
if key in info:
@ -73,6 +75,20 @@ dependency_links = {
'branch': branch,
'series': series,
},
'product_cross_reference':
'hg+https://bitbucket.org/datalife_sco/'
'trytond-product_cross_reference@%(branch)s'
'#egg=datalife_product_cross_reference-%(series)s' % {
'branch': branch,
'series': series,
},
'party_edi':
'hg+https://bitbucket.org/nantic/'
'trytond-party_edi@%(branch)s'
'#egg=nantic_party_edi-%(series)s' % {
'branch': branch,
'series': series,
},
}
requires = []

View File

@ -1,11 +1,9 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/form/separator[@id='inventory']" position="before">
<label name="edocument_sequence"/>
<field name="edocument_sequence"/>
<label name="EDI_output_path"/>
<field name="EDI_output_path"/>
</xpath>
</data>
<form>
<label name="edocument_sequence"/>
<field name="edocument_sequence"/>
<label name="export_path"/>
<field name="export_path"/>
</form>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form>
<label name="message_type"/>
<field name="message_type"/>
<label name="party"/>
<field name="party"/>
<label name="template"/>
<field name="template"/>
</form>

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tree>
<field name="message_type"/>
<field name="party"/>
</tree>