mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge branch 'mig/17.0/delivery_partner_ups' into '17.0'
WIP: mig/17.0/delivery_partner_ups into 17.0 See merge request hibou-io/hibou-odoo/suite!1690
This commit is contained in:
29
delivery_partner_ups/README.rst
Normal file
29
delivery_partner_ups/README.rst
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
***************************************
|
||||||
|
Hibou - UPS Partner Shipping Accounts
|
||||||
|
***************************************
|
||||||
|
|
||||||
|
Adds UPS shipping accounts.
|
||||||
|
|
||||||
|
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
|
||||||
|
|
||||||
|
|
||||||
|
=============
|
||||||
|
Main Features
|
||||||
|
=============
|
||||||
|
|
||||||
|
* Adds UPS to the delivery type selection field.
|
||||||
|
* Adds new required field of UPS Account ZIP.
|
||||||
|
* Validates entered UPS account numbers are the correct length.
|
||||||
|
|
||||||
|
.. image:: https://user-images.githubusercontent.com/15882954/41176879-e7dc5a66-6b16-11e8-82a2-9b6cd0c909fd.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_ups/__init__.py
Normal file
1
delivery_partner_ups/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
25
delivery_partner_ups/__manifest__.py
Executable file
25
delivery_partner_ups/__manifest__.py
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
'name': 'UPS Partner Shipping Accounts',
|
||||||
|
'author': 'Hibou Corp.',
|
||||||
|
'version': '17.0.1.0.0',
|
||||||
|
'license': 'LGPL-3',
|
||||||
|
'category': 'Stock',
|
||||||
|
'sequence': 95,
|
||||||
|
'summary': 'UPS Partner Shipping Accounts',
|
||||||
|
'description': """
|
||||||
|
UPS Partner Shipping Accounts
|
||||||
|
=============================
|
||||||
|
This module adds UPS to the delivery type selection dropdown on the Partner Shipping Account model.
|
||||||
|
Additionally, it adds a new required field UPS Account ZIP, as well as validation of entered UPS account number.
|
||||||
|
|
||||||
|
""",
|
||||||
|
'website': 'https://hibou.io/',
|
||||||
|
'depends': [
|
||||||
|
'delivery_partner',
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'views/delivery_views.xml',
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'application': False,
|
||||||
|
}
|
||||||
47
delivery_partner_ups/i18n/es.po
Normal file
47
delivery_partner_ups/i18n/es.po
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * delivery_partner_ups
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 15.0+e\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2021-10-12 01:10+0000\n"
|
||||||
|
"PO-Revision-Date: 2021-10-12 01:10+0000\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: \n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
|
#. module: delivery_partner_ups
|
||||||
|
#: model:ir.model.fields,field_description:delivery_partner_ups.field_partner_shipping_account__delivery_type
|
||||||
|
msgid "Carrier"
|
||||||
|
msgstr "Transportista"
|
||||||
|
|
||||||
|
#. module: delivery_partner_ups
|
||||||
|
#: model:ir.model,name:delivery_partner_ups.model_partner_shipping_account
|
||||||
|
msgid "Partner Shipping Account"
|
||||||
|
msgstr "Cuenta de Envío del Socio"
|
||||||
|
|
||||||
|
#. module: delivery_partner_ups
|
||||||
|
#: model:ir.model.fields.selection,name:delivery_partner_ups.selection__partner_shipping_account__delivery_type__ups
|
||||||
|
msgid "UPS"
|
||||||
|
msgstr "UPS"
|
||||||
|
|
||||||
|
#. module: delivery_partner_ups
|
||||||
|
#: model:ir.model.fields,field_description:delivery_partner_ups.field_partner_shipping_account__ups_zip
|
||||||
|
msgid "UPS Account ZIP"
|
||||||
|
msgstr "Código postal de la cuenta UPS"
|
||||||
|
#. module: delivery_partner_ups
|
||||||
|
#: code:addons/delivery_partner_ups/models/delivery.py:0
|
||||||
|
#, python-format
|
||||||
|
msgid "UPS Account numbers must be 6 Alpha-numeric characters."
|
||||||
|
msgstr "Los números de cuenta de UPS deben tener 6 caracteres alfanuméricos."
|
||||||
|
|
||||||
|
#. module: delivery_partner_ups
|
||||||
|
#: code:addons/delivery_partner_ups/models/delivery.py:0
|
||||||
|
#, python-format
|
||||||
|
msgid "UPS requires the 5 digit account ZIP."
|
||||||
|
msgstr "UPS requiere el código postal de 5 dígitos de la cuenta."
|
||||||
1
delivery_partner_ups/models/__init__.py
Normal file
1
delivery_partner_ups/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import delivery
|
||||||
19
delivery_partner_ups/models/delivery.py
Normal file
19
delivery_partner_ups/models/delivery.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
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=[('ups', 'UPS')], ondelete={'ups': 'set default'})
|
||||||
|
ups_zip = fields.Char(string='UPS Account ZIP')
|
||||||
|
|
||||||
|
def ups_check_validity(self):
|
||||||
|
m = re.search(r'^[\dA-Z]{6}$', self.name or '')
|
||||||
|
if not m:
|
||||||
|
raise ValidationError(_('UPS Account numbers must be 6 Alpha-numeric characters.'))
|
||||||
|
m = re.search(r'^\d{5}$', self.ups_zip or '')
|
||||||
|
if not m:
|
||||||
|
raise ValidationError(_('UPS requires the 5 digit account ZIP.'))
|
||||||
1
delivery_partner_ups/tests/__init__.py
Normal file
1
delivery_partner_ups/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_ups_account
|
||||||
61
delivery_partner_ups/tests/test_ups_account.py
Normal file
61
delivery_partner_ups/tests/test_ups_account.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
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_ups_account_information(self):
|
||||||
|
# Create object and confirm that validation error raises if ups account number is blank or not 8 digits
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
wrong_account_number = self.PartnerShippingAccount.create({
|
||||||
|
'name': '1234567',
|
||||||
|
'description': 'Error Account',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'delivery_type': 'ups',
|
||||||
|
'note': 'This is a note',
|
||||||
|
'ups_zip': '12345'
|
||||||
|
})
|
||||||
|
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
no_account_number = self.PartnerShippingAccount.create({
|
||||||
|
'name': '',
|
||||||
|
'description': 'Error Account',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'delivery_type': 'ups',
|
||||||
|
'note': 'This is a note',
|
||||||
|
'ups_zip': '12345'
|
||||||
|
})
|
||||||
|
# Create object and confirm that validation error raises if zipcode is blank or not 5 digits
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
wrong_zip_code = self.PartnerShippingAccount.create({
|
||||||
|
'name': '123456',
|
||||||
|
'description': 'Error Account',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'delivery_type': 'ups',
|
||||||
|
'note': 'This is a note',
|
||||||
|
'ups_zip': '1234'
|
||||||
|
})
|
||||||
|
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
no_zip_code = self.PartnerShippingAccount.create({
|
||||||
|
'name': '123456',
|
||||||
|
'description': 'Error Account',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'delivery_type': 'ups',
|
||||||
|
'note': 'This is a note',
|
||||||
|
'ups_zip': ''
|
||||||
|
})
|
||||||
|
|
||||||
|
_ = self.PartnerShippingAccount.create({
|
||||||
|
'name': '123456',
|
||||||
|
'description': 'Error Account',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'delivery_type': 'ups',
|
||||||
|
'note': 'This is a note',
|
||||||
|
'ups_zip': '12345'
|
||||||
|
})
|
||||||
15
delivery_partner_ups/views/delivery_views.xml
Normal file
15
delivery_partner_ups/views/delivery_views.xml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="partner_shipping_account_view_form_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">partner.shipping.account.form.inherit</field>
|
||||||
|
<field name="model">partner.shipping.account</field>
|
||||||
|
<field name="inherit_id" ref="delivery_partner.partner_shipping_account_view_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//group[@name='carrier']" position="inside">
|
||||||
|
<field name="ups_zip"
|
||||||
|
invisible="not delivery_type == 'ups'"
|
||||||
|
required= "delivery_type == 'ups'"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user