mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[REM] sale_exception_portal: available in professional
H14528
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
from . import models
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
'name': 'Sale Exception Portal',
|
|
||||||
'summary': 'Display sale exceptions on customer portal',
|
|
||||||
'version': '16.0.1.0.0',
|
|
||||||
'author': "Hibou Corp.",
|
|
||||||
'category': 'Sale',
|
|
||||||
'license': 'AGPL-3',
|
|
||||||
'website': "https://hibou.io",
|
|
||||||
'description': """
|
|
||||||
Display sale exceptions on customer portal and prevent further action
|
|
||||||
""",
|
|
||||||
'depends': [
|
|
||||||
'sale_exception',
|
|
||||||
],
|
|
||||||
'demo': [],
|
|
||||||
'data': [
|
|
||||||
'views/sale_portal_templates.xml',
|
|
||||||
'views/sale_views.xml',
|
|
||||||
],
|
|
||||||
'auto_install': False,
|
|
||||||
'installable': True,
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
from . import sale
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
from odoo import fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class ExceptionRule(models.Model):
|
|
||||||
_inherit = 'exception.rule'
|
|
||||||
|
|
||||||
website_description = fields.Text('Description for Website')
|
|
||||||
|
|
||||||
|
|
||||||
class SaleOrder(models.Model):
|
|
||||||
_inherit = 'sale.order'
|
|
||||||
|
|
||||||
def _check_sale_order_exceptions(self):
|
|
||||||
exception_ids = self.detect_exceptions()
|
|
||||||
exceptions = self.env['exception.rule'].browse(exception_ids)
|
|
||||||
reasons = [{'title': ex.name, 'description': ex.website_description or ex.description} for ex in exceptions]
|
|
||||||
return reasons
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
from . import test_check_so_exceptions
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
from odoo.tests.common import TransactionCase
|
|
||||||
|
|
||||||
|
|
||||||
class TestCheckSOExceptions(TransactionCase):
|
|
||||||
def setUp(self):
|
|
||||||
super(TestCheckSOExceptions, self).setUp()
|
|
||||||
|
|
||||||
self.azure_customer = self.browse_ref('base.res_partner_12')
|
|
||||||
|
|
||||||
self.exception_rule = self.env['exception.rule'].create({
|
|
||||||
'name': 'No Azure',
|
|
||||||
'description': 'No sales to Azure',
|
|
||||||
'active': True,
|
|
||||||
'model': 'sale.order',
|
|
||||||
'exception_type': 'by_py_code',
|
|
||||||
'code': 'failed = object.partner_id and object.partner_id.id == %d' % self.azure_customer.id
|
|
||||||
})
|
|
||||||
|
|
||||||
self.sale_product = self.browse_ref('product.product_product_5')
|
|
||||||
self.sale_product.standard_price = 100.0
|
|
||||||
|
|
||||||
def test_00_check_so_exceptions(self):
|
|
||||||
sale_order = self.env['sale.order'].create({
|
|
||||||
'partner_id': self.azure_customer.id,
|
|
||||||
'order_line': [(0, 0, {
|
|
||||||
'product_id': self.sale_product.id,
|
|
||||||
'product_uom_qty': 1.0,
|
|
||||||
'price_unit': 50.0,
|
|
||||||
})],
|
|
||||||
})
|
|
||||||
|
|
||||||
exceptions = sale_order._check_sale_order_exceptions()
|
|
||||||
self.assertEqual(len(exceptions), 1)
|
|
||||||
self.assertEqual(exceptions[0].get('description'), 'No sales to Azure')
|
|
||||||
|
|
||||||
self.exception_rule.website_description = 'Different message for website'
|
|
||||||
exceptions = sale_order._check_sale_order_exceptions()
|
|
||||||
self.assertEqual(len(exceptions), 1)
|
|
||||||
self.assertEqual(exceptions[0].get('description'), 'Different message for website')
|
|
||||||
|
|
||||||
self.exception_rule.active = False
|
|
||||||
exceptions = sale_order._check_sale_order_exceptions()
|
|
||||||
self.assertEqual(len(exceptions), 0)
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<template id="sale_order_portal_template_inherit" inherit_id="sale.sale_order_portal_template">
|
|
||||||
<!-- LEFT COLUMN ACTIONS -->
|
|
||||||
<xpath expr="//li[1]" position="replace">
|
|
||||||
<t t-set="sale_order_exceptions" t-value="sale_order._check_sale_order_exceptions()"/>
|
|
||||||
<li class="list-group-item flex-grow-1">
|
|
||||||
<a t-if="sale_order._has_to_be_signed(True) and not sale_order_exceptions"
|
|
||||||
role="button" class="btn btn-primary btn-block mb8"
|
|
||||||
data-toggle="modal"
|
|
||||||
data-target="#modalaccept"
|
|
||||||
href="#">
|
|
||||||
<i class="fa fa-check"/>
|
|
||||||
<t t-if="sale_order._has_to_be_paid(True)"> Sign & Pay</t>
|
|
||||||
<t t-else=""> Accept & Sign</t>
|
|
||||||
</a>
|
|
||||||
<a t-elif="sale_order._has_to_be_paid(True) and not sale_order_exceptions"
|
|
||||||
role="button"
|
|
||||||
id="o_sale_portal_paynow"
|
|
||||||
data-toggle="modal"
|
|
||||||
data-target="#modalaccept"
|
|
||||||
href="#"
|
|
||||||
t-att-class="'btn-block mb8 %s' % ('btn btn-light' if sale_order.transaction_ids else 'btn btn-primary')">
|
|
||||||
<i class="fa fa-check"/>
|
|
||||||
<t t-if="not sale_order.signature">Accept & Pay</t>
|
|
||||||
<t t-else="">Pay Now</t>
|
|
||||||
</a>
|
|
||||||
<t t-if="sale_order_exceptions">
|
|
||||||
<t t-foreach="sale_order_exceptions" t-as="exception">
|
|
||||||
<a href="#discussion" role="button" class="btn btn-danger btn-block mb8"
|
|
||||||
style="max-width: 180px;">
|
|
||||||
<i class="fa fa-warning"/>
|
|
||||||
<span t-esc="exception['description']"/>
|
|
||||||
</a>
|
|
||||||
</t>
|
|
||||||
</t>
|
|
||||||
</li>
|
|
||||||
</xpath>
|
|
||||||
|
|
||||||
<!-- BOTTOM ACTIONS -->
|
|
||||||
<xpath expr="//div[@t-if='sale_order._has_to_be_signed(True) or sale_order._has_to_be_paid(True)']" position="replace">
|
|
||||||
<div t-if="sale_order._has_to_be_signed(True) or sale_order._has_to_be_paid(True)"
|
|
||||||
class="row justify-content-center text-center d-print-none pt-1 pb-4">
|
|
||||||
<t t-set="sale_order_exceptions" t-value="sale_order._check_sale_order_exceptions()"/>
|
|
||||||
<t t-if="sale_order._has_to_be_signed(True)">
|
|
||||||
<div t-if="not sale_order_exceptions" class="col-sm-auto mt8">
|
|
||||||
<a role="button" class="btn btn-primary" data-toggle="modal"
|
|
||||||
data-target="#modalaccept" href="#">
|
|
||||||
<i class="fa fa-check"/>
|
|
||||||
<t t-if="sale_order.has_to_be_paid(True)"> Sign & Pay</t>
|
|
||||||
<t t-else=""> Accept & Sign</t>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-auto mt8">
|
|
||||||
<a role="button" class="btn btn-secondary" href="#discussion">
|
|
||||||
<i class="fa fa-comment"/> Feedback</a>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-auto mt8">
|
|
||||||
<a role="button" class="btn btn-danger" data-toggle="modal"
|
|
||||||
data-target="#modaldecline" href="#"> <i class="fa fa-times"/> Reject</a>
|
|
||||||
</div>
|
|
||||||
</t>
|
|
||||||
<div t-elif="sale_order._has_to_be_paid(True) and not sale_order_exceptions" class="col-sm-auto mt8">
|
|
||||||
<a role="button" data-toggle="modal" data-target="#modalaccept" href="#"
|
|
||||||
t-att-class="'%s' % ('btn btn-light' if sale_order.transaction_ids else 'btn btn-primary')">
|
|
||||||
<i class="fa fa-check"/> <t t-if="not sale_order.signature">Accept & Pay</t>
|
|
||||||
<t t-else="">Pay Now</t>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</xpath>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<record id="exception_rule_form_inherit" model="ir.ui.view">
|
|
||||||
<field name="name">exception.rule.form.inherit</field>
|
|
||||||
<field name="model">exception.rule</field>
|
|
||||||
<field name="inherit_id" ref="base_exception.view_exception_rule_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='description']" position="after">
|
|
||||||
<field name="website_description"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
Reference in New Issue
Block a user