Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement keychain backend to laposte #120

Open
wants to merge 1 commit into
base: 10-roulier
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion delivery_roulier/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Delivery Carrier Roulier',
'version': '10.0.1.0.0',
'version': '10.0.1.0.1',
'author': 'Akretion,Odoo Community Association (OCA)',
'summary': 'Integration of multiple carriers',
'maintainer': 'Akretion, Odoo Community Association (OCA)',
Expand All @@ -21,6 +21,7 @@
'website': 'http://www.akretion.com/',
'data': [
'views/stock_quant_package.xml',
'views/keychain_backend.xml',
],
'external_dependencies': {
'python': [
Expand Down
1 change: 1 addition & 0 deletions delivery_roulier/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import stock_picking
from . import stock_quant_package
from . import keychain_backend
33 changes: 33 additions & 0 deletions delivery_roulier/models/keychain_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Akretion (http://www.akretion.com).
# @author Raphael Reverdy <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models, api


class KeychainBackendRoulier(models.Model):
_name = 'keychain.backend.roulier'
_inherit = 'keychain.backend'

namespace = fields.Selection([])

# TODO: move it in keychainbackend ?
login = fields.Char(
compute="_compute_login",
inverse="_inverse_login",
required=True)

@api.multi
def _inverse_login(self):
for record in self:
account = self._get_keychain_account()
if record.login:
account.login = record.login

@api.multi
def _compute_login(self):
for record in self:
account = record._get_existing_keychain()
if account and account.login:
record.login = account.login
73 changes: 73 additions & 0 deletions delivery_roulier/views/keychain_backend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<record id="roulier_backend_view_tree" model="ir.ui.view">
<field name="model">keychain.backend.roulier</field>
<field name="arch" type="xml">
<tree string="Carrier Accounts">
<field name="name"/>
<field name="namespace" />
</tree>
</field>
</record>

<record id="roulier_backend_view_form" model="ir.ui.view">
<field name="model">keychain.backend.roulier</field>
<field name="arch" type="xml">
<form string="Carrier Account">
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1>
<field name="name"/>
</h1>
</div>
<group name="config">
<field name="namespace"/>
</group>
</sheet>
</form>
</field>
</record>

<record id="roulier_backend_view_search" model="ir.ui.view">
<field name="model">keychain.backend.roulier</field>
<field name="arch" type="xml">
<search string="Carrier account">
<field name="name"/>
</search>
</field>
</record>

<record model="ir.actions.act_window" id="act_open_roulier_backend_view">
<field name="name">Carrier Accounts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">keychain.backend.roulier</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="roulier_backend_view_search"/>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>

<record model="ir.actions.act_window.view" id="act_open_roulier_backend_view_form">
<field name="act_window_id" ref="act_open_roulier_backend_view"/>
<field name="sequence" eval="20"/>
<field name="view_mode">form</field>
<field name="view_id" ref="roulier_backend_view_form"/>
</record>

<record model="ir.actions.act_window.view" id="act_open_roulier_backend_view_tree">
<field name="act_window_id" ref="act_open_roulier_backend_view"/>
<field name="sequence" eval="10"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="roulier_backend_view_tree"/>
</record>


<menuitem id="menu_roulier_backend"
parent="delivery.menu_delivery"
sequence="10"
action="act_open_roulier_backend_view"/>

</odoo>
3 changes: 2 additions & 1 deletion delivery_roulier_laposte/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
'name': 'Delivery Carrier La Poste (fr)',
'version': '10.0.1.0.0',
'version': '10.0.1.0.1',
'author': 'Akretion',
'summary': 'Generate Label for La Poste/Colissimo',
'maintainer': 'Akretion,Odoo Community Association (OCA)',
Expand All @@ -20,6 +20,7 @@
'data/delivery.xml',
'data/keychain.xml',
'views/stock_picking.xml',
'views/keychain_backend.xml',
],
'external_dependencies': {
'python': [
Expand Down
4 changes: 2 additions & 2 deletions delivery_roulier_laposte/data/keychain.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="keychain_la_poste" model="keychain.account">
<record id="keychain_la_poste" model="keychain.backend.roulier">
<field name="name">La Poste default</field>
<field name="namespace">roulier_laposte</field>
<field name="technical_name">laposte_default_account</field>
</record>

</odoo>
2 changes: 1 addition & 1 deletion delivery_roulier_laposte/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import stock_picking
from . import delivery
from . import stock_quant_package
from . import keychain
from . import keychain
10 changes: 9 additions & 1 deletion delivery_roulier_laposte/models/keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
LAPOSTE_KEYCHAIN_NAMESPACE = 'roulier_laposte'


class AccountProduct(models.Model):
class KeychainAccount(models.Model):
_inherit = 'keychain.account'

namespace = fields.Selection(
Expand All @@ -23,3 +23,11 @@ def _roulier_laposte_init_data(self):

def _roulier_laposte_validate_data(self, data):
return True


class KeychainBackend(models.Model):
_inherit = 'keychain.backend.roulier'
_backend_name = 'roulier_laposte'

namespace = fields.Selection(
selection_add=[(LAPOSTE_KEYCHAIN_NAMESPACE, 'Laposte')])
17 changes: 17 additions & 0 deletions delivery_roulier_laposte/views/keychain_backend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<record id="laposte_roulier_backend_view_form" model="ir.ui.view">
<field name="model">keychain.backend.roulier</field>
<field name="inherit_id" ref="roulier_backend_view_form" />
<field name="arch" type="xml">
<group name="config" position="after">
<group name="Laposte" string="Laposte" attrs="{'invisible': [('namespace', '!=', 'roulier_laposte')]}">
<field name="login" attrs="{'required': [('namespace', '=', 'roulier_laposte')]}"/>
<field name="password" attrs="{'required': [('namespace', '=', 'roulier_laposte')]}"/>
</group>
</group>
</field>
</record>

</odoo>