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:
Akim Juillerat
2018-01-11 14:57:10 +01:00
parent f470bb7be5
commit e3b2f67dec
17 changed files with 342 additions and 347 deletions

View File

@@ -88,9 +88,9 @@ Credits
Contributors Contributors
============ ============
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
* Guewen Baconnier <guewen.baconnier@camptocamp.com> * Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Anar Baghirli <a.baghirli@mobilunity.com> * Anar Baghirli <a.baghirli@mobilunity.com>
* Akim Juillerat <akim.juillerat@camptocamp.com>
Maintainer Maintainer
========== ==========

View File

@@ -3,7 +3,4 @@
# Copyright 2012-2017 Camptocamp SA # Copyright 2012-2017 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import ir_attachment from . import models
from . import pingen
from . import pingen_document
from . import res_company

View File

@@ -11,16 +11,16 @@
'license': 'AGPL-3', 'license': 'AGPL-3',
'category': 'Reporting', 'category': 'Reporting',
'complexity': 'easy', 'complexity': 'easy',
'depends': [], 'depends': ['base_setup'],
'external_dependencies': { 'external_dependencies': {
'python': ['requests'], 'python': ['requests'],
}, },
'website': 'http://www.camptocamp.com', 'website': 'http://www.camptocamp.com',
'data': [ 'data': [
'ir_attachment_view.xml', 'views/ir_attachment_view.xml',
'pingen_document_view.xml', 'views/pingen_document_view.xml',
'pingen_data.xml', 'data/pingen_data.xml',
'res_company_view.xml', 'views/base_config_settings.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
], ],
'tests': [], 'tests': [],

View 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>

View File

@@ -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>

View 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

View 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')

View File

@@ -24,8 +24,7 @@ class IrAttachment(models.Model):
pingen_speed = fields.Selection( pingen_speed = fields.Selection(
[('1', 'Priority'), ('2', 'Economy')], [('1', 'Priority'), ('2', 'Economy')],
'Speed', default='2', 'Speed', default='2',
help='Defines the sending speed if ' + help='Defines the sending speed if the document is automatically sent')
'the document is automatically sent')
pingen_color = fields.Selection([('0', 'B/W'), ('1', 'Color')], pingen_color = fields.Selection([('0', 'B/W'), ('1', 'Color')],
'Type of print', 'Type of print',
default='0') default='0')
@@ -62,17 +61,16 @@ class IrAttachment(models.Model):
if document: if document:
if document.state == 'pushed': if document.state == 'pushed':
raise UserError( raise UserError(
_('Error. The attachment ' + _('Error. The attachment %s is '
'%s is already pushed to pingen.com.') % 'already pushed to pingen.com.') % self.name)
self.name)
document.write({'state': 'canceled'}) document.write({'state': 'canceled'})
return return
def create(self, vals): def create(self, vals):
attachment_id = super(IrAttachment, self).create(vals) attachment = super(IrAttachment, self).create(vals)
if 'send_to_pingen' in vals: if 'send_to_pingen' in vals:
attachment_id._handle_pingen_document() attachment._handle_pingen_document()
return attachment_id return attachment
def write(self, vals): def write(self, vals):
res = super(IrAttachment, self).write(vals) res = super(IrAttachment, self).write(vals)

View File

@@ -8,7 +8,6 @@ import logging
import urlparse import urlparse
import json import json
import pytz import pytz
import base64
from datetime import datetime from datetime import datetime
from requests.packages.urllib3.filepost import encode_multipart_formdata from requests.packages.urllib3.filepost import encode_multipart_formdata
@@ -47,10 +46,6 @@ class PingenException(RuntimeError):
request.""" request."""
class ConnectionError(PingenException):
"""An Error occured with the pingen API"""
class APIError(PingenException): class APIError(PingenException):
"""An Error occured with the pingen API""" """An Error occured with the pingen API"""
@@ -117,11 +112,6 @@ class Pingen(object):
response = method(complete_url, **kwargs) response = method(complete_url, **kwargs)
if not response.ok:
raise ConnectionError(
"%s: %s" % (response.json()['errorcode'],
response.json()['errormessage']))
if response.json()['error']: if response.json()['error']:
raise APIError( raise APIError(
"%s: %s" % (response.json()['errorcode'], "%s: %s" % (response.json()['errorcode'],

View File

@@ -4,15 +4,14 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging import logging
from requests.exceptions import ConnectionError
from cStringIO import StringIO from cStringIO import StringIO
# from contextlib import closing import odoo
from odoo import models, fields, _ from odoo import models, fields, _
from odoo.exceptions import UserError from odoo.exceptions import UserError
import odoo from .pingen import APIError, pingen_datetime_to_utc, POST_SENDING_STATUS
from .pingen import APIError, ConnectionError, \
POST_SENDING_STATUS, pingen_datetime_to_utc
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@@ -119,27 +118,37 @@ class PingenDocument(models.Model):
instance) for public interface. instance) for public interface.
""" """
self.ensure_one() self.ensure_one()
for document in self: state = False
error_msg = False
try: try:
session = self._get_pingen_session() session = self._get_pingen_session()
document._push_to_pingen(pingen=session) self._push_to_pingen(pingen=session)
except ConnectionError as e: except ConnectionError as e:
raise UserError( state = 'error'
_('Connection Error when asking for ' + error_msg = _('Connection Error when asking for '
'sending the document %s to Pingen') 'sending the document %s to Pingen') % self.name
% document.name)
except APIError as e: except APIError as e:
raise UserError( state = 'pingen_error'
_('Error when asking Pingen to send the document %s: ' error_msg = _('Error when asking Pingen to send the document %s: '
'\n%s') % (document.name, e)) '\n%s') % (self.name, e)
except Exception as e: except Exception as e:
_logger.exception( _logger.exception(
'Unexcepted Error when updating ' + 'Unexpected Error when updating ' +
'the status of pingen.document %s: ' % 'the status of pingen.document %s: ' %
document.id) self.id)
raise UserError( error_msg = _('Unexpected Error when updating the '
_('Unexcepted Error when updating the ' + 'status of Document %s') % self.name
'status of Document %s') % document.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 return True
def _push_and_send_to_pingen_cron(self): def _push_and_send_to_pingen_cron(self):
@@ -172,7 +181,7 @@ class PingenDocument(models.Model):
document.write({'last_error_message': e, document.write({'last_error_message': e,
'state': 'pingen_error'}) 'state': 'pingen_error'})
except BaseException as e: except BaseException as e:
_logger.error('Unexcepted error in pingen cron') _logger.error('Unexpected error in pingen cron')
return True return True
def _resolve_error(self): def _resolve_error(self):
@@ -232,28 +241,26 @@ class PingenDocument(models.Model):
instance) for public interface. instance) for public interface.
""" """
self.ensure_one() self.ensure_one()
for document in self:
try: try:
session = document._get_pingen_session() session = self._get_pingen_session()
document._ask_pingen_send(pingen=session) self._ask_pingen_send(pingen=session)
except ConnectionError as e: except ConnectionError as e:
raise UserError( raise UserError(
_('Connection Error when asking for ' _('Connection Error when asking for '
'sending the document %s to Pingen') % document.name) 'sending the document %s to Pingen') % self.name)
except APIError as e: except APIError as e:
raise UserError( raise UserError(
_('Error when asking Pingen to send the document %s: ' _('Error when asking Pingen to send the document %s: '
'\n%s') % (document.name, e)) '\n%s') % (self.name, e))
except BaseException as e: except BaseException as e:
_logger.exception( _logger.exception(
'Unexcepted Error when updating the ' + 'Unexpected Error when updating the status '
'status of pingen.document %s: ' % 'of pingen.document %s: ' % self.id)
document.id)
raise UserError( raise UserError(
_('Unexcepted Error when updating the ' + _('Unexpected Error when updating the status '
'status of Document %s') % document.name) 'of Document %s') % self.name)
return True return True
def _update_post_infos(self, pingen): def _update_post_infos(self, pingen):
@@ -277,19 +284,15 @@ class PingenDocument(models.Model):
'Pingen Document %s to %s.' % 'Pingen Document %s to %s.' %
(self.id, pingen.url)) (self.id, pingen.url))
raise raise
# currency_ids = self.env['res.currency'].search(
# [('name', '=', post_infos['currency'])])
country = self.env['res.country'].search( country = self.env['res.country'].search(
[('code', '=', post_infos['country'])]) [('code', '=', post_infos['country'])])
send_date = pingen_datetime_to_utc(post_infos['date']) send_date = pingen_datetime_to_utc(post_infos['date'])
vals = { vals = {
# 'post_status': POST_SENDING_STATUS[post_infos['status']], 'post_status': POST_SENDING_STATUS[post_infos['status']],
# 'cost': post_infos['cost'],
# 'currency_id': currency_ids[0] if currency_ids else False,
'parsed_address': post_infos['address'], '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), 'send_date': fields.Datetime.to_string(send_date),
# 'pages': post_infos['pages'], 'pages': post_infos['pages'],
'last_error_message': False, 'last_error_message': False,
} }
if pingen.is_posted(post_infos): if pingen.is_posted(post_infos):
@@ -330,26 +333,22 @@ class PingenDocument(models.Model):
instance) for public interface. instance) for public interface.
""" """
self.ensure_one() self.ensure_one()
for document in self:
try: try:
session = document._get_pingen_session() session = self._get_pingen_session()
document._update_post_infos(pingen=session) self._update_post_infos(pingen=session)
except ConnectionError as e: except ConnectionError as e:
raise UserError( raise UserError(
_('Connection Error when updating ' + _('Connection Error when updating the status '
'the status of Document %s' 'of Document %s from Pingen') % self.name)
' from Pingen') % document.name)
except APIError as e: except APIError as e:
raise UserError( raise UserError(
_('Error when updating the status ' + _('Error when updating the status of Document %s from '
'of Document %s from Pingen: ' 'Pingen: \n%s') % (self.name, e))
'\n%s') % (document.name, e))
except BaseException as e: except BaseException as e:
_logger.exception( _logger.exception(
'Unexcepted Error when updating ' + 'Unexpected Error when updating the status '
'the status of pingen.document %s: ' % 'of pingen.document %s: ' % self.id)
document.id)
raise UserError( raise UserError(
_('Unexcepted Error when updating ' + _('Unexpected Error when updating the status '
'the status of Document %s') % document.name) 'of Document %s') % self.name)
return True return True

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View 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>

View 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>

View 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>