mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
Finish migration to version 10.0
Do not raise ConnectionError if we get a response Use ConnectionError from requests lib instead of overriding it Fix push_to_pingen (writes on state as for cron), remove unneeded loops
This commit is contained in:
@@ -88,9 +88,9 @@ Credits
|
||||
Contributors
|
||||
============
|
||||
|
||||
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
|
||||
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
||||
* Anar Baghirli <a.baghirli@mobilunity.com>
|
||||
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
||||
|
||||
Maintainer
|
||||
==========
|
||||
|
||||
@@ -3,7 +3,4 @@
|
||||
# Copyright 2012-2017 Camptocamp SA
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import ir_attachment
|
||||
from . import pingen
|
||||
from . import pingen_document
|
||||
from . import res_company
|
||||
from . import models
|
||||
@@ -11,16 +11,16 @@
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Reporting',
|
||||
'complexity': 'easy',
|
||||
'depends': [],
|
||||
'depends': ['base_setup'],
|
||||
'external_dependencies': {
|
||||
'python': ['requests'],
|
||||
},
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'data': [
|
||||
'ir_attachment_view.xml',
|
||||
'pingen_document_view.xml',
|
||||
'pingen_data.xml',
|
||||
'res_company_view.xml',
|
||||
'views/ir_attachment_view.xml',
|
||||
'views/pingen_document_view.xml',
|
||||
'data/pingen_data.xml',
|
||||
'views/base_config_settings.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'tests': [],
|
||||
|
||||
32
pingen/data/pingen_data.xml
Normal file
32
pingen/data/pingen_data.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
|
||||
<record forcecreate="True" id="ir_cron_push_pingen" model="ir.cron">
|
||||
<field name="name">Run Pingen Document Push</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="function">_push_and_send_to_pingen_cron</field>
|
||||
<field name="args">()</field>
|
||||
</record>
|
||||
|
||||
<record forcecreate="True" id="ir_cron_update_pingen" model="ir.cron">
|
||||
<field name="name">Run Pingen Document Update</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="function">_update_post_infos_cron</field>
|
||||
<field name="args">()</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="view_attachment_form" model="ir.ui.view">
|
||||
<field name="name">ir.attachment.pingen.view</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_attachment_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group/group[2]" position="after">
|
||||
<group string="Pingen info" groups="base.group_no_one">
|
||||
<field name="send_to_pingen"/>
|
||||
<field name="pingen_send" attrs="{'required': [('send_to_pingen', '=', True)]}"/>
|
||||
<field name="pingen_speed" attrs="{'required': [('pingen_send', '=', True)]}"/>
|
||||
<field name="pingen_color" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window
|
||||
context="{'search_default_attachment_id': [active_id], 'default_attachment_id': active_id}"
|
||||
id="act_attachment_to_pingen_document"
|
||||
name="Pingen Document"
|
||||
groups=""
|
||||
res_model="pingen.document"
|
||||
src_model="ir.attachment"/>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
8
pingen/models/__init__.py
Normal file
8
pingen/models/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import ir_attachment
|
||||
from . import pingen
|
||||
from . import pingen_document
|
||||
from . import res_company
|
||||
from . import base_config_settings
|
||||
11
pingen/models/base_config_settings.py
Normal file
11
pingen/models/base_config_settings.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class BaseConfigSettings(models.TransientModel):
|
||||
_inherit = 'base.config.settings'
|
||||
|
||||
pingen_token = fields.Char(related='company_id.pingen_token')
|
||||
pingen_staging = fields.Boolean(related='company_id.pingen_staging')
|
||||
@@ -24,8 +24,7 @@ class IrAttachment(models.Model):
|
||||
pingen_speed = fields.Selection(
|
||||
[('1', 'Priority'), ('2', 'Economy')],
|
||||
'Speed', default='2',
|
||||
help='Defines the sending speed if ' +
|
||||
'the document is automatically sent')
|
||||
help='Defines the sending speed if the document is automatically sent')
|
||||
pingen_color = fields.Selection([('0', 'B/W'), ('1', 'Color')],
|
||||
'Type of print',
|
||||
default='0')
|
||||
@@ -62,17 +61,16 @@ class IrAttachment(models.Model):
|
||||
if document:
|
||||
if document.state == 'pushed':
|
||||
raise UserError(
|
||||
_('Error. The attachment ' +
|
||||
'%s is already pushed to pingen.com.') %
|
||||
self.name)
|
||||
_('Error. The attachment %s is '
|
||||
'already pushed to pingen.com.') % self.name)
|
||||
document.write({'state': 'canceled'})
|
||||
return
|
||||
|
||||
def create(self, vals):
|
||||
attachment_id = super(IrAttachment, self).create(vals)
|
||||
attachment = super(IrAttachment, self).create(vals)
|
||||
if 'send_to_pingen' in vals:
|
||||
attachment_id._handle_pingen_document()
|
||||
return attachment_id
|
||||
attachment._handle_pingen_document()
|
||||
return attachment
|
||||
|
||||
def write(self, vals):
|
||||
res = super(IrAttachment, self).write(vals)
|
||||
@@ -8,7 +8,6 @@ import logging
|
||||
import urlparse
|
||||
import json
|
||||
import pytz
|
||||
import base64
|
||||
|
||||
from datetime import datetime
|
||||
from requests.packages.urllib3.filepost import encode_multipart_formdata
|
||||
@@ -47,10 +46,6 @@ class PingenException(RuntimeError):
|
||||
request."""
|
||||
|
||||
|
||||
class ConnectionError(PingenException):
|
||||
"""An Error occured with the pingen API"""
|
||||
|
||||
|
||||
class APIError(PingenException):
|
||||
"""An Error occured with the pingen API"""
|
||||
|
||||
@@ -117,11 +112,6 @@ class Pingen(object):
|
||||
|
||||
response = method(complete_url, **kwargs)
|
||||
|
||||
if not response.ok:
|
||||
raise ConnectionError(
|
||||
"%s: %s" % (response.json()['errorcode'],
|
||||
response.json()['errormessage']))
|
||||
|
||||
if response.json()['error']:
|
||||
raise APIError(
|
||||
"%s: %s" % (response.json()['errorcode'],
|
||||
@@ -4,15 +4,14 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
import logging
|
||||
|
||||
from requests.exceptions import ConnectionError
|
||||
from cStringIO import StringIO
|
||||
|
||||
# from contextlib import closing
|
||||
import odoo
|
||||
from odoo import models, fields, _
|
||||
from odoo.exceptions import UserError
|
||||
import odoo
|
||||
from .pingen import APIError, ConnectionError, \
|
||||
POST_SENDING_STATUS, pingen_datetime_to_utc
|
||||
from .pingen import APIError, pingen_datetime_to_utc, POST_SENDING_STATUS
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -119,27 +118,37 @@ class PingenDocument(models.Model):
|
||||
instance) for public interface.
|
||||
"""
|
||||
self.ensure_one()
|
||||
for document in self:
|
||||
try:
|
||||
session = self._get_pingen_session()
|
||||
document._push_to_pingen(pingen=session)
|
||||
except ConnectionError as e:
|
||||
raise UserError(
|
||||
_('Connection Error when asking for ' +
|
||||
'sending the document %s to Pingen')
|
||||
% document.name)
|
||||
except APIError as e:
|
||||
raise UserError(
|
||||
_('Error when asking Pingen to send the document %s: '
|
||||
'\n%s') % (document.name, e))
|
||||
except Exception as e:
|
||||
_logger.exception(
|
||||
'Unexcepted Error when updating ' +
|
||||
'the status of pingen.document %s: ' %
|
||||
document.id)
|
||||
raise UserError(
|
||||
_('Unexcepted Error when updating the ' +
|
||||
'status of Document %s') % document.name)
|
||||
state = False
|
||||
error_msg = False
|
||||
try:
|
||||
session = self._get_pingen_session()
|
||||
self._push_to_pingen(pingen=session)
|
||||
except ConnectionError as e:
|
||||
state = 'error'
|
||||
error_msg = _('Connection Error when asking for '
|
||||
'sending the document %s to Pingen') % self.name
|
||||
except APIError as e:
|
||||
state = 'pingen_error'
|
||||
error_msg = _('Error when asking Pingen to send the document %s: '
|
||||
'\n%s') % (self.name, e)
|
||||
except Exception as e:
|
||||
_logger.exception(
|
||||
'Unexpected Error when updating ' +
|
||||
'the status of pingen.document %s: ' %
|
||||
self.id)
|
||||
error_msg = _('Unexpected Error when updating the '
|
||||
'status of Document %s') % self.name
|
||||
finally:
|
||||
if error_msg:
|
||||
vals = {'last_error_message': error_msg}
|
||||
if state:
|
||||
vals.update({'state': state})
|
||||
with odoo.registry(self.env.cr.dbname).cursor() as new_cr:
|
||||
new_env = odoo.api.Environment(
|
||||
new_cr, self.env.uid, self.env.context)
|
||||
self.with_env(new_env).write(vals)
|
||||
|
||||
raise UserError(error_msg)
|
||||
return True
|
||||
|
||||
def _push_and_send_to_pingen_cron(self):
|
||||
@@ -172,7 +181,7 @@ class PingenDocument(models.Model):
|
||||
document.write({'last_error_message': e,
|
||||
'state': 'pingen_error'})
|
||||
except BaseException as e:
|
||||
_logger.error('Unexcepted error in pingen cron')
|
||||
_logger.error('Unexpected error in pingen cron')
|
||||
return True
|
||||
|
||||
def _resolve_error(self):
|
||||
@@ -232,28 +241,26 @@ class PingenDocument(models.Model):
|
||||
instance) for public interface.
|
||||
"""
|
||||
self.ensure_one()
|
||||
for document in self:
|
||||
try:
|
||||
session = document._get_pingen_session()
|
||||
document._ask_pingen_send(pingen=session)
|
||||
except ConnectionError as e:
|
||||
raise UserError(
|
||||
_('Connection Error when asking for '
|
||||
'sending the document %s to Pingen') % document.name)
|
||||
try:
|
||||
session = self._get_pingen_session()
|
||||
self._ask_pingen_send(pingen=session)
|
||||
except ConnectionError as e:
|
||||
raise UserError(
|
||||
_('Connection Error when asking for '
|
||||
'sending the document %s to Pingen') % self.name)
|
||||
|
||||
except APIError as e:
|
||||
raise UserError(
|
||||
_('Error when asking Pingen to send the document %s: '
|
||||
'\n%s') % (document.name, e))
|
||||
except APIError as e:
|
||||
raise UserError(
|
||||
_('Error when asking Pingen to send the document %s: '
|
||||
'\n%s') % (self.name, e))
|
||||
|
||||
except BaseException as e:
|
||||
_logger.exception(
|
||||
'Unexcepted Error when updating the ' +
|
||||
'status of pingen.document %s: ' %
|
||||
document.id)
|
||||
raise UserError(
|
||||
_('Unexcepted Error when updating the ' +
|
||||
'status of Document %s') % document.name)
|
||||
except BaseException as e:
|
||||
_logger.exception(
|
||||
'Unexpected Error when updating the status '
|
||||
'of pingen.document %s: ' % self.id)
|
||||
raise UserError(
|
||||
_('Unexpected Error when updating the status '
|
||||
'of Document %s') % self.name)
|
||||
return True
|
||||
|
||||
def _update_post_infos(self, pingen):
|
||||
@@ -277,19 +284,15 @@ class PingenDocument(models.Model):
|
||||
'Pingen Document %s to %s.' %
|
||||
(self.id, pingen.url))
|
||||
raise
|
||||
# currency_ids = self.env['res.currency'].search(
|
||||
# [('name', '=', post_infos['currency'])])
|
||||
country = self.env['res.country'].search(
|
||||
[('code', '=', post_infos['country'])])
|
||||
send_date = pingen_datetime_to_utc(post_infos['date'])
|
||||
vals = {
|
||||
# 'post_status': POST_SENDING_STATUS[post_infos['status']],
|
||||
# 'cost': post_infos['cost'],
|
||||
# 'currency_id': currency_ids[0] if currency_ids else False,
|
||||
'post_status': POST_SENDING_STATUS[post_infos['status']],
|
||||
'parsed_address': post_infos['address'],
|
||||
'country_id': country.id if country else False,
|
||||
'country_id': country.id,
|
||||
'send_date': fields.Datetime.to_string(send_date),
|
||||
# 'pages': post_infos['pages'],
|
||||
'pages': post_infos['pages'],
|
||||
'last_error_message': False,
|
||||
}
|
||||
if pingen.is_posted(post_infos):
|
||||
@@ -330,26 +333,22 @@ class PingenDocument(models.Model):
|
||||
instance) for public interface.
|
||||
"""
|
||||
self.ensure_one()
|
||||
for document in self:
|
||||
try:
|
||||
session = document._get_pingen_session()
|
||||
document._update_post_infos(pingen=session)
|
||||
except ConnectionError as e:
|
||||
raise UserError(
|
||||
_('Connection Error when updating ' +
|
||||
'the status of Document %s'
|
||||
' from Pingen') % document.name)
|
||||
except APIError as e:
|
||||
raise UserError(
|
||||
_('Error when updating the status ' +
|
||||
'of Document %s from Pingen: '
|
||||
'\n%s') % (document.name, e))
|
||||
except BaseException as e:
|
||||
_logger.exception(
|
||||
'Unexcepted Error when updating ' +
|
||||
'the status of pingen.document %s: ' %
|
||||
document.id)
|
||||
raise UserError(
|
||||
_('Unexcepted Error when updating ' +
|
||||
'the status of Document %s') % document.name)
|
||||
try:
|
||||
session = self._get_pingen_session()
|
||||
self._update_post_infos(pingen=session)
|
||||
except ConnectionError as e:
|
||||
raise UserError(
|
||||
_('Connection Error when updating the status '
|
||||
'of Document %s from Pingen') % self.name)
|
||||
except APIError as e:
|
||||
raise UserError(
|
||||
_('Error when updating the status of Document %s from '
|
||||
'Pingen: \n%s') % (self.name, e))
|
||||
except BaseException as e:
|
||||
_logger.exception(
|
||||
'Unexpected Error when updating the status '
|
||||
'of pingen.document %s: ' % self.id)
|
||||
raise UserError(
|
||||
_('Unexpected Error when updating the status '
|
||||
'of Document %s') % self.name)
|
||||
return True
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record forcecreate="True" id="ir_cron_push_pingen" model="ir.cron">
|
||||
<field name="name">Run Pingen Document Push</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="function">_push_and_send_to_pingen_cron</field>
|
||||
<field name="args">()</field>
|
||||
</record>
|
||||
|
||||
<record forcecreate="True" id="ir_cron_update_pingen" model="ir.cron">
|
||||
<field name="name">Run Pingen Document Update</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="function">_update_post_infos_cron</field>
|
||||
<field name="args">()</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,161 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="0">
|
||||
|
||||
<record id="view_pingen_document_tree" model="ir.ui.view">
|
||||
<field name="name">pingen.document.tree</field>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Pingen Document">
|
||||
<field name="name"/>
|
||||
<field name="datas_fname"/>
|
||||
<field name="pingen_send"/>
|
||||
<field name="pingen_speed"/>
|
||||
<field name="pingen_color"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_pingen_document_form" model="ir.ui.view">
|
||||
<field name="name">pingen.document.form</field>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Pingen Document">
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" readonly="True"/>
|
||||
<field name="type" readonly="True"/>
|
||||
<field name="company_id" readonly="True" groups="base.group_multi_company" widget="selection"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Pingen.com">
|
||||
<separator string="Options" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="2">
|
||||
<field name="pingen_send" attrs="{'readonly': [('state', 'in', ['sendcenter', 'sent'])]}"/>
|
||||
<field name="pingen_speed" attrs="{'readonly': [('state', 'in', ['sendcenter', 'sent'])], 'required': [('pingen_send', '=', True)]}"/>
|
||||
<field name="pingen_color" attrs="{'readonly': [('state', 'in', ['sendcenter', 'sent'])]}"/>
|
||||
</group>
|
||||
|
||||
<separator string="Dates" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="2">
|
||||
<field name="push_date"/>
|
||||
</group>
|
||||
|
||||
<group colspan="4" attrs="{'invisible': [('last_error_message', '=', False)]}">
|
||||
<separator string="Errors" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="2">
|
||||
<field nolabel="1" name="last_error_message"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<group colspan="4" attrs="{'invisible': [('state', 'not in', ['sendcenter', 'sent'])]}">
|
||||
<separator string="Sendcenter" colspan="4"/>
|
||||
<newline />
|
||||
<group col="4" colspan="2">
|
||||
<field colspan="4" name="post_status"/>
|
||||
<group col="3" colspan="2">
|
||||
<field name="cost"/>
|
||||
<field colspan="1" nolabel="1" name="currency_id"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="parsed_address"/>
|
||||
<field name="country_id"/>
|
||||
<field name="send_date"/>
|
||||
<field name="pages"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<separator string="Actions" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="2">
|
||||
<button name="push_to_pingen" type="object"
|
||||
states="pending"
|
||||
string="Push to pingen.com" icon="terp-stage"/>
|
||||
<button name="ask_pingen_send" type="object"
|
||||
states="pushed"
|
||||
string="Ask pingen.com to send the document" icon="gtk-print"/>
|
||||
<button name="resolve_error" type="object"
|
||||
states="error,pingen_error"
|
||||
string="Errors resolved" icon="gtk-redo"/>
|
||||
<button name="update_post_infos" type="object"
|
||||
states="sendcenter"
|
||||
string="Update the letter's informations" icon="gtk-refresh"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Attachment">
|
||||
<group col="4" colspan="4">
|
||||
<separator string="Data" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="4" attrs="{'invisible':[('type','=','url')]}">
|
||||
<field name="datas" filename="datas_fname" readonly="True"/>
|
||||
<field name="datas_fname" select="1" readonly="True"/>
|
||||
</group>
|
||||
<group col="2" colspan="4" attrs="{'invisible':[('type','=','binary')]}">
|
||||
<field name="url" widget="url" readonly="True"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2" colspan="4">
|
||||
<separator string="Attached To" colspan="2"/>
|
||||
<field name="attachment_id"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visible="pending,pushed,sent"
|
||||
statusbar_colors='{"error":"red","pingen_error":"red","canceled":"grey","pushed":"blue","sent":"green"}'/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_pingen_document_search" model="ir.ui.view">
|
||||
<field name="name">pingen.document.search</field>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Pingen Document">
|
||||
<filter icon="terp-project"
|
||||
string="Pending"
|
||||
domain="[('state','=','pending')]"/>
|
||||
<filter icon="terp-stage"
|
||||
string="Pushed"
|
||||
domain="[('state','=','pushed')]"/>
|
||||
<filter icon="gtk-print"
|
||||
string="In Sendcenter"
|
||||
domain="[('state','=','sendcenter')]"/>
|
||||
<filter icon="kanban-apply"
|
||||
string="Sent"
|
||||
domain="[('state','=','sent')]"/>
|
||||
<filter icon="kanban-stop"
|
||||
string="Error"
|
||||
domain="[('state','=','error')]"/>
|
||||
<filter icon="STOCK_NO"
|
||||
string="Pingen Error"
|
||||
domain="[('state','=','pingen_error')]"/>
|
||||
<filter icon="terp-dialog-close"
|
||||
string="Canceled"
|
||||
domain="[('state','=','canceled')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="attachment_id" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_pingen_document" model="ir.actions.act_window">
|
||||
<field name="name">Pingen Documents</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pingen.document</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="view_pingen_document_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_pingen_document" id="menu_pingen_document" parent="base.next_id_9"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<record model="ir.ui.view" id="view_company_inherit_form">
|
||||
<field name="name">res.company.form.inherit</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_company_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[1]" position="after">
|
||||
<page name="pingenconf" string="Pingen Information">
|
||||
<group name="ping_gr_1">
|
||||
<field name="pingen_token" groups="base.group_system"/>
|
||||
<field name="pingen_staging" groups="base.group_system"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</openerp>
|
||||
16
pingen/views/base_config_settings.xml
Normal file
16
pingen/views/base_config_settings.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="base_config_settings_inherit" model="ir.ui.view">
|
||||
<field name="name">base.config.settings.inherit</field>
|
||||
<field name="inherit_id" ref="base_setup.view_general_configuration"/>
|
||||
<field name="model">base.config.settings</field>
|
||||
<field name="arch" type="xml">
|
||||
<group name="report" position="before">
|
||||
<group string="Pingen Integration">
|
||||
<field name="pingen_token" groups="base.group_system"/>
|
||||
<field name="pingen_staging" groups="base.group_system"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
27
pingen/views/ir_attachment_view.xml
Normal file
27
pingen/views/ir_attachment_view.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_attachment_form" model="ir.ui.view">
|
||||
<field name="name">ir.attachment.pingen.view</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_attachment_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group/group[2]" position="after">
|
||||
<group string="Pingen info" groups="base.group_no_one">
|
||||
<field name="send_to_pingen"/>
|
||||
<field name="pingen_send" attrs="{'required': [('send_to_pingen', '=', True)]}"/>
|
||||
<field name="pingen_speed" attrs="{'required': [('pingen_send', '=', True)]}"/>
|
||||
<field name="pingen_color" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window
|
||||
context="{'search_default_attachment_id': [active_id], 'default_attachment_id': active_id}"
|
||||
id="act_attachment_to_pingen_document"
|
||||
name="Pingen Document"
|
||||
groups=""
|
||||
res_model="pingen.document"
|
||||
src_model="ir.attachment"/>
|
||||
</odoo>
|
||||
160
pingen/views/pingen_document_view.xml
Normal file
160
pingen/views/pingen_document_view.xml
Normal file
@@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_pingen_document_tree" model="ir.ui.view">
|
||||
<field name="name">pingen.document.tree</field>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Pingen Document">
|
||||
<field name="name"/>
|
||||
<field name="datas_fname"/>
|
||||
<field name="pingen_send"/>
|
||||
<field name="pingen_speed"/>
|
||||
<field name="pingen_color"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_pingen_document_form" model="ir.ui.view">
|
||||
<field name="name">pingen.document.form</field>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Pingen Document">
|
||||
<header>
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visible="pending,pushed,sent"
|
||||
statusbar_colors='{"error":"red","pingen_error":"red","canceled":"grey","pushed":"blue","sent":"green"}'/>
|
||||
</header>
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" readonly="True"/>
|
||||
<field name="type" readonly="True"/>
|
||||
<field name="company_id" readonly="True" groups="base.group_multi_company" widget="selection"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Pingen.com">
|
||||
<separator string="Options" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="2">
|
||||
<field name="pingen_send" attrs="{'readonly': [('state', 'in', ['sendcenter', 'sent'])]}"/>
|
||||
<field name="pingen_speed" attrs="{'readonly': [('state', 'in', ['sendcenter', 'sent'])], 'required': [('pingen_send', '=', True)]}"/>
|
||||
<field name="pingen_color" attrs="{'readonly': [('state', 'in', ['sendcenter', 'sent'])]}"/>
|
||||
</group>
|
||||
|
||||
<separator string="Dates" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="2">
|
||||
<field name="push_date"/>
|
||||
</group>
|
||||
|
||||
<group colspan="4" attrs="{'invisible': [('last_error_message', '=', False)]}">
|
||||
<separator string="Errors" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="2">
|
||||
<field nolabel="1" name="last_error_message"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<group colspan="4" attrs="{'invisible': [('state', 'not in', ['sendcenter', 'sent'])]}">
|
||||
<separator string="Sendcenter" colspan="4"/>
|
||||
<newline />
|
||||
<group col="4" colspan="2">
|
||||
<field colspan="4" name="post_status"/>
|
||||
<group col="3" colspan="2">
|
||||
<field name="cost"/>
|
||||
<field colspan="1" nolabel="1" name="currency_id"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="parsed_address"/>
|
||||
<field name="country_id"/>
|
||||
<field name="send_date"/>
|
||||
<field name="pages"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<separator string="Actions" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="2">
|
||||
<button name="push_to_pingen" type="object"
|
||||
states="pending"
|
||||
string="Push to pingen.com" icon="fa-upload"/>
|
||||
<button name="ask_pingen_send" type="object"
|
||||
states="pushed"
|
||||
string="Ask pingen.com to send the document" icon="fa-share"/>
|
||||
<button name="resolve_error" type="object"
|
||||
states="error,pingen_error"
|
||||
string="Errors resolved" icon="fa-repeat"/>
|
||||
<button name="update_post_infos" type="object"
|
||||
states="sendcenter"
|
||||
string="Update the letter's informations" icon="fa-refresh"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Attachment">
|
||||
<group col="4" colspan="4">
|
||||
<separator string="Data" colspan="4"/>
|
||||
<newline />
|
||||
<group col="2" colspan="4" attrs="{'invisible':[('type','=','url')]}">
|
||||
<field name="datas" filename="datas_fname" readonly="True"/>
|
||||
<field name="datas_fname" select="1" readonly="True"/>
|
||||
</group>
|
||||
<group col="2" colspan="4" attrs="{'invisible':[('type','=','binary')]}">
|
||||
<field name="url" widget="url" readonly="True"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2" colspan="4">
|
||||
<separator string="Attached To" colspan="2"/>
|
||||
<field name="attachment_id"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_pingen_document_search" model="ir.ui.view">
|
||||
<field name="name">pingen.document.search</field>
|
||||
<field name="model">pingen.document</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Pingen Document">
|
||||
<filter icon="terp-project"
|
||||
string="Pending"
|
||||
domain="[('state','=','pending')]"/>
|
||||
<filter icon="terp-stage"
|
||||
string="Pushed"
|
||||
domain="[('state','=','pushed')]"/>
|
||||
<filter icon="gtk-print"
|
||||
string="In Sendcenter"
|
||||
domain="[('state','=','sendcenter')]"/>
|
||||
<filter icon="kanban-apply"
|
||||
string="Sent"
|
||||
domain="[('state','=','sent')]"/>
|
||||
<filter icon="kanban-stop"
|
||||
string="Error"
|
||||
domain="[('state','=','error')]"/>
|
||||
<filter icon="STOCK_NO"
|
||||
string="Pingen Error"
|
||||
domain="[('state','=','pingen_error')]"/>
|
||||
<filter icon="terp-dialog-close"
|
||||
string="Canceled"
|
||||
domain="[('state','=','canceled')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="attachment_id" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_pingen_document" model="ir.actions.act_window">
|
||||
<field name="name">Pingen Documents</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pingen.document</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="view_pingen_document_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_pingen_document" id="menu_pingen_document"/>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user