mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge branch 'mig/15.0/sale_exception_user' into '15.0'
mig/15.0/sale_exception_user into 15.0 See merge request hibou-io/hibou-odoo/suite!1287
This commit is contained in:
3
sale_exception_user/__init__.py
Normal file
3
sale_exception_user/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from . import wizard
|
||||
23
sale_exception_user/__manifest__.py
Normal file
23
sale_exception_user/__manifest__.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name': 'Sale Exception Rule User',
|
||||
'version': '15.0.1.0.0',
|
||||
'author': 'Hibou Corp.',
|
||||
'license': 'OPL-1',
|
||||
'category': 'Generic Modules',
|
||||
'summary': 'Allow users to ignore sale exceptions',
|
||||
'description': """
|
||||
Allow users to ignore sale exceptions
|
||||
""",
|
||||
'website': 'https://hibou.io/',
|
||||
'depends': [
|
||||
'base_exception_user',
|
||||
'sale_exception',
|
||||
],
|
||||
'data': [
|
||||
'wizard/sale_exception_confirm_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
3
sale_exception_user/tests/__init__.py
Normal file
3
sale_exception_user/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from . import test_sale_exception_user
|
||||
59
sale_exception_user/tests/test_sale_exception_user.py
Normal file
59
sale_exception_user/tests/test_sale_exception_user.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import Form, TransactionCase
|
||||
|
||||
|
||||
class TestSaleException(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
groups = (cls.env.ref('base_exception_user.group_exception_rule_user') |
|
||||
cls.env.ref('sales_team.group_sale_manager'))
|
||||
user_dict = {
|
||||
"name": "User test",
|
||||
"login": "tua@example.com",
|
||||
"password": "base-test-passwd",
|
||||
"email": "armande.hruser@example.com",
|
||||
"groups_id": [(6, 0, groups.ids)],
|
||||
}
|
||||
cls.user_test = cls.env['res.users'].create(user_dict)
|
||||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
|
||||
|
||||
def test_sale_exception_user(self):
|
||||
with self.with_user(self.user_test.login):
|
||||
exception = self.env.ref("sale_exception.excep_no_zip").sudo()
|
||||
exception.active = True
|
||||
exception.allow_user_ignore = True
|
||||
|
||||
partner = self.env.ref("base.res_partner_1")
|
||||
partner.zip = False
|
||||
p = self.env.ref("product.product_product_6")
|
||||
so1 = self.env["sale.order"].create(
|
||||
{
|
||||
"partner_id": partner.id,
|
||||
"partner_invoice_id": partner.id,
|
||||
"partner_shipping_id": partner.id,
|
||||
"order_line": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"name": p.name,
|
||||
"product_id": p.id,
|
||||
"product_uom_qty": 2,
|
||||
"product_uom": p.uom_id.id,
|
||||
"price_unit": p.list_price,
|
||||
},
|
||||
)
|
||||
],
|
||||
"pricelist_id": self.env.ref("product.list0").id,
|
||||
}
|
||||
)
|
||||
|
||||
action = so1.action_confirm()
|
||||
wizard = Form(self.env[action['res_model']].with_user(self.user_test).with_context(action['context'])).save()
|
||||
self.assertTrue(wizard.show_ignore_button)
|
||||
action = wizard.action_ignore()
|
||||
self.assertEqual(action.get('type'), 'ir.actions.act_window_close')
|
||||
self.assertTrue(so1.ignore_exception)
|
||||
self.assertEqual(so1.state, 'sale')
|
||||
3
sale_exception_user/wizard/__init__.py
Normal file
3
sale_exception_user/wizard/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from . import sale_exception_confirm
|
||||
18
sale_exception_user/wizard/sale_exception_confirm.py
Normal file
18
sale_exception_user/wizard/sale_exception_confirm.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class SaleExceptionConfirm(models.TransientModel):
|
||||
_inherit = 'sale.exception.confirm'
|
||||
|
||||
def action_confirm(self):
|
||||
res = super().action_confirm()
|
||||
if self.ignore:
|
||||
self.related_model_id.action_confirm()
|
||||
return res
|
||||
|
||||
def _action_ignore(self):
|
||||
self.related_model_id.ignore_exception = True
|
||||
self.related_model_id.action_confirm()
|
||||
return super()._action_ignore()
|
||||
18
sale_exception_user/wizard/sale_exception_confirm_view.xml
Normal file
18
sale_exception_user/wizard/sale_exception_confirm_view.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_sale_exception_confirm" model="ir.ui.view">
|
||||
<field name="name">Sale Exceptions User</field>
|
||||
<field name="model">sale.exception.confirm</field>
|
||||
<field name="inherit_id" ref="sale_exception.view_sale_exception_confirm"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='ignore']" position="after">
|
||||
<field name="show_ignore_button" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='action_confirm']" position="after">
|
||||
<button name="action_ignore" string="Ignore" colspan="1" type="object" attrs="{'invisible': [('show_ignore_button', '=', False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user