Merge branch 'mig/13.0/delivery_partner_fedex' into '13.0-test'

mig/13.0/delivery_partner_fedex into 13.0-test

See merge request hibou-io/hibou-odoo/suite!598
This commit is contained in:
Hibou Bot
2020-11-05 21:33:13 +00:00
7 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
***************************************
Hibou - FedEx Partner Shipping Accounts
***************************************
Adds FedEx shipping accounts.
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
=============
Main Features
=============
* Adds FedEx to the delivery type selection field.
* Validates entered FedEx account numbers are the correct length.
.. image:: https://user-images.githubusercontent.com/15882954/41176817-b7353356-6b16-11e8-8545-3e59b7b350ae.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

View File

@@ -0,0 +1,2 @@
from . import models
from . import tests

View File

@@ -0,0 +1,18 @@
{
'name': 'Fedex Partner Shipping Accounts',
'author': 'Hibou Corp. <hello@hibou.io>',
'version': '12.0.1.0.0',
'category': 'Stock',
'sequence': 95,
'summary': 'Fedex Partner Shipping Accounts',
'description': """
""",
'website': 'https://hibou.io/',
'depends': [
'delivery_partner',
],
'data': [
],
'installable': True,
'application': False,
}

View File

@@ -0,0 +1 @@
from . import delivery

View 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=[('fedex', 'FedEx')])
def fedex_check_validity(self):
m = re.search(r'^\d{9}$', self.name or '')
if not m:
raise ValidationError('FedEx Account numbers must be 9 decimal numbers.')

View File

@@ -0,0 +1 @@
from . import test_fedex_account

View File

@@ -0,0 +1,29 @@
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']
def test_fedex_account_information(self):
# Create object and confirm that validation error raises if fedex account is blank or not 8 digits
with self.assertRaises(ValidationError):
wrong_account_number = self.PartnerShippingAccount.create({
'name': '12345678',
'description': 'Error Account',
'partner_id': 5,
'delivery_type': 'fedex',
'note': 'This is a note'
})
with self.assertRaises(ValidationError):
no_account_number = self.PartnerShippingAccount.create({
'name': '',
'description': 'Error Account',
'partner_id': 5,
'delivery_type': 'fedex',
'note': 'This is a note'
})