mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge branch 'mig/13.0/delivery_partner_dhl' into '13.0'
mig/13.0/delivery_partner_dhl into 13.0 See merge request hibou-io/hibou-odoo/suite!597
This commit is contained in:
28
delivery_partner_dhl/README.rst
Normal file
28
delivery_partner_dhl/README.rst
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
*************************************
|
||||||
|
Hibou - DHL Partner Shipping Accounts
|
||||||
|
*************************************
|
||||||
|
|
||||||
|
Adds DHL shipping accounts.
|
||||||
|
|
||||||
|
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
|
||||||
|
|
||||||
|
|
||||||
|
=============
|
||||||
|
Main Features
|
||||||
|
=============
|
||||||
|
|
||||||
|
* Adds DHL to the delivery type selection field.
|
||||||
|
* Validates entered DHL account numbers are the correct length.
|
||||||
|
|
||||||
|
.. image:: https://user-images.githubusercontent.com/15882954/41176760-825c6802-6b16-11e8-91b6-188b32146626.png
|
||||||
|
:alt: 'Register Payment Detail'
|
||||||
|
:width: 988
|
||||||
|
:align: left
|
||||||
|
|
||||||
|
=======
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
|
||||||
|
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/11.0/LICENSE>`_.
|
||||||
|
|
||||||
|
Copyright Hibou Corp. 2018
|
||||||
1
delivery_partner_dhl/__init__.py
Normal file
1
delivery_partner_dhl/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
18
delivery_partner_dhl/__manifest__.py
Executable file
18
delivery_partner_dhl/__manifest__.py
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
'name': 'DHL Partner Shipping Accounts',
|
||||||
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
|
'version': '13.0.1.0.0',
|
||||||
|
'category': 'Stock',
|
||||||
|
'sequence': 95,
|
||||||
|
'summary': 'DHL Partner Shipping Accounts',
|
||||||
|
'description': """
|
||||||
|
""",
|
||||||
|
'website': 'https://hibou.io/',
|
||||||
|
'depends': [
|
||||||
|
'delivery_partner',
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'application': False,
|
||||||
|
}
|
||||||
1
delivery_partner_dhl/models/__init__.py
Normal file
1
delivery_partner_dhl/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import delivery
|
||||||
17
delivery_partner_dhl/models/delivery.py
Normal file
17
delivery_partner_dhl/models/delivery.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class PartnerShippingAccount(models.Model):
|
||||||
|
_inherit = 'partner.shipping.account'
|
||||||
|
|
||||||
|
delivery_type = fields.Selection(selection_add=[('dhl', 'DHL')])
|
||||||
|
|
||||||
|
def dhl_check_validity(self):
|
||||||
|
m = re.search(r'^(\d{8}|\d{9}|\d{10})$', self.name or '')
|
||||||
|
if not m:
|
||||||
|
raise ValidationError('DHL Account numbers must be 8-10 decimal numbers.')
|
||||||
|
|
||||||
|
|
||||||
1
delivery_partner_dhl/tests/__init__.py
Normal file
1
delivery_partner_dhl/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_dhl_account
|
||||||
38
delivery_partner_dhl/tests/test_dhl_account.py
Normal file
38
delivery_partner_dhl/tests/test_dhl_account.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
from odoo.tests.common import TransactionCase
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class TestAccount(TransactionCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestAccount, self).setUp()
|
||||||
|
self.PartnerShippingAccount = self.env['partner.shipping.account']
|
||||||
|
self.partner = self.env.ref('base.res_partner_12')
|
||||||
|
|
||||||
|
def test_dhl_account_information(self):
|
||||||
|
# Create object and confirm
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
wrong_account_number = self.PartnerShippingAccount.create({
|
||||||
|
'name': '1234567',
|
||||||
|
'description': 'Error Account',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'delivery_type': 'dhl',
|
||||||
|
'note': 'This is a note'
|
||||||
|
})
|
||||||
|
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
no_account_number = self.PartnerShippingAccount.create({
|
||||||
|
'name': '',
|
||||||
|
'description': 'Error Account',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'delivery_type': 'dhl',
|
||||||
|
'note': 'This is a note'
|
||||||
|
})
|
||||||
|
|
||||||
|
_ = self.PartnerShippingAccount.create({
|
||||||
|
'name': '123456789',
|
||||||
|
'description': 'Success',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'delivery_type': 'dhl',
|
||||||
|
'note': 'This is a note'
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user