forked from OCA/delivery-carrier
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
83 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from . import models | ||
|
||
from .decorator import implemented_by_carrier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# coding: utf-8 | ||
# @author Raphael Reverdy <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from functools import wraps | ||
|
||
|
||
def implemented_by_carrier(func): | ||
"""Decorator: call _carrier_prefixed method instead. | ||
Usage: | ||
@implemented_by_carrier | ||
def _do_something() | ||
def _laposte_do_something() | ||
def _gls_do_something() | ||
At runtime, picking._do_something() will try to call | ||
the carrier spectific method or fallback to generic _do_something | ||
""" | ||
@wraps(func) | ||
def wrapper(cls, *args, **kwargs): | ||
fun_name = func.__name__ | ||
|
||
def get_carrier_type(cls, *args, **kwargs): | ||
if hasattr(cls, 'carrier_type'): | ||
return cls.carrier_type | ||
pickings = [ | ||
obj for obj in args | ||
if getattr(obj, '_name', '') == 'stock.picking'] | ||
if len(pickings) > 0: | ||
return pickings[0].carrier_type | ||
if cls[0].carrier_id: | ||
return cls[0].carrier_id.carrier_type | ||
|
||
carrier_type = get_carrier_type(cls, *args, **kwargs) | ||
fun = '_%s%s' % (carrier_type, fun_name) | ||
if not hasattr(cls, fun): | ||
fun = '_roulier%s' % (fun_name) | ||
return getattr(cls, fun)(*args, **kwargs) | ||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ | |
# David BEAL <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from functools import wraps | ||
import logging | ||
import base64 | ||
|
||
from openerp import models, api, fields | ||
from openerp.tools.translate import _ | ||
from openerp.exceptions import UserError | ||
from odoo import models, api, fields | ||
from odoo.tools.translate import _ | ||
from odoo.exceptions import UserError | ||
|
||
from ..decorator import implemented_by_carrier | ||
|
||
_logger = logging.getLogger(__name__) | ||
try: | ||
|
@@ -22,44 +23,6 @@ | |
_logger.debug('Cannot `import roulier`.') | ||
|
||
|
||
def implemented_by_carrier(func): | ||
"""Decorator: call _carrier_prefixed method instead. | ||
Usage: | ||
@implemented_by_carrier | ||
def _do_something() | ||
def _laposte_do_something() | ||
def _gls_do_something() | ||
At runtime, picking._do_something() will try to call | ||
the carrier spectific method or fallback to generic _do_something | ||
""" | ||
@wraps(func) | ||
def wrapper(cls, *args, **kwargs): | ||
fun_name = func.__name__ | ||
|
||
def get_carrier_type(cls, *args, **kwargs): | ||
if hasattr(cls, 'carrier_type'): | ||
return cls.carrier_type | ||
# TODO: est-ce bien utile si on carrier_id ? | ||
pickings = [ | ||
obj for obj in args | ||
if getattr(obj, '_name', '') == 'stock.picking'] | ||
if len(pickings) > 0: | ||
return pickings[0].carrier_type | ||
if cls[0].carrier_id: | ||
return cls[0].carrier_id.carrier_type | ||
|
||
carrier_type = get_carrier_type(cls, *args, **kwargs) | ||
fun = '_%s%s' % (carrier_type, fun_name) | ||
if not hasattr(cls, fun): | ||
fun = '_roulier%s' % (fun_name) | ||
# return func(cls, *args, **kwargs) | ||
return getattr(cls, fun)(*args, **kwargs) | ||
return wrapper | ||
|
||
|
||
class StockQuantPackage(models.Model): | ||
_inherit = 'stock.quant.package' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
# coding: utf-8 | ||
# © 2016 Raphael REVERDY <[email protected]> | ||
# © 2017 Raphael REVERDY <[email protected]> | ||
# David BEAL <[email protected]> | ||
# Sébastien BEAU <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
'name': 'Delivery Carrier La Poste (fr)', | ||
'version': '9.0.1.0.0', | ||
'version': '10.0.1.0.0', | ||
'author': 'Akretion', | ||
'summary': 'Generate Label for La Poste/Colissimo', | ||
'maintainer': 'Akretion,Odoo Community Association (OCA)', | ||
|
@@ -19,6 +18,7 @@ | |
'website': 'http://www.akretion.com/', | ||
'data': [ | ||
'data/delivery.xml', | ||
'data/keychain.xml', | ||
'views/stock_picking.xml', | ||
], | ||
'external_dependencies': { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<!--<data noupdate="1">--> | ||
<data> | ||
<odoo> | ||
<record id="keychain_la_poste" model="keychain.account"> | ||
<field name="name">La Poste default</field> | ||
<field name="namespace">roulier_laposte</field> | ||
<field name="technical_name">laposte_default_account</field> | ||
</record> | ||
</data> | ||
</openerp> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from . import company | ||
from . import stock_picking | ||
from . import delivery | ||
from . import stock_quant_package | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,12 @@ | |
# David BEAL <[email protected]> | ||
# Sébastien BEAU | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
from openerp import models, fields, api | ||
from openerp.exceptions import Warning as UserError | ||
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT | ||
|
||
from datetime import datetime, timedelta | ||
|
||
from odoo import models, fields, api | ||
from odoo.exceptions import UserError | ||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
@@ -107,7 +105,7 @@ def _laposte_convert_address(self, partner): | |
""" | ||
address = self._roulier_convert_address(partner) or {} | ||
# get_split_adress from partner_helper module | ||
streets = partner._get_split_address(partner, 3, 38) | ||
streets = partner._get_split_address(3, 38) | ||
address['street'], address['street2'], address['street3'] = streets | ||
# TODO manage in a better way if partner_firstname is installed | ||
address['firstName'] = '.' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
# David BEAL <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import _, api, models | ||
import logging | ||
from odoo import _, api, models | ||
|
||
_logger = logging.getLogger(__name__) | ||
try: | ||
|
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.