Browse Source

Nov 10: [FIX] Bug Fixed 'auto_save_restrict'

pull/406/merge
Risvana Cybro 1 week ago
parent
commit
4beb76dc8c
  1. 1
      auto_save_restrict/__init__.py
  2. 2
      auto_save_restrict/__manifest__.py
  3. 1
      auto_save_restrict/models/__init__.py
  4. 73
      auto_save_restrict/models/sale_order.py
  5. 24
      auto_save_restrict/static/description/index.html

1
auto_save_restrict/__init__.py

@ -19,3 +19,4 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from . import models

2
auto_save_restrict/__manifest__.py

@ -32,7 +32,7 @@
'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions',
'website': 'https://www.cybrosys.com',
'depends': ['base'],
'depends': ['base','sale'],
'assets': {
'web.assets_backend': [
'auto_save_restrict/static/src/js/form_controller.js',

1
auto_save_restrict/models/__init__.py

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

73
auto_save_restrict/models/sale_order.py

@ -0,0 +1,73 @@
from odoo import models, api, _
from odoo.exceptions import UserError
class SaleOrder(models.Model):
_inherit = 'sale.order'
def action_confirm(self):
""" Confirm the given quotation(s) and set their confirmation date.
If the corresponding setting is enabled, also locks the Sale Order.
:return: True
:rtype: bool
:raise: UserError if trying to confirm cancelled SO's
"""
# Filter out orders that are already confirmed or don't need confirmation
orders_to_confirm = self.env['sale.order']
for order in self:
error_msg = order._confirmation_error_message()
if error_msg:
if order.state in ('sale', 'done', 'cancel'):
continue
raise UserError(error_msg)
orders_to_confirm |= order
# If no orders to confirm, return early
if not orders_to_confirm:
return True
orders_to_confirm.order_line._validate_analytic_distribution()
for order in orders_to_confirm:
# ensure the record exists in DB before checking followers
if not order.id:
order.flush()
# Refresh follower cache
order.invalidate_recordset(['message_partner_ids'])
# Check if already followed directly in DB
self.env.cr.execute("""
SELECT 1 FROM mail_followers
WHERE res_model = %s AND res_id = %s AND partner_id = %s
LIMIT 1
""", ('sale.order', order.id, order.partner_id.id))
already_follower = self.env.cr.fetchone()
if not already_follower:
try:
with self.env.cr.savepoint():
order.message_subscribe([order.partner_id.id])
except Exception:
pass # partner already subscribed (race condition, etc.)
orders_to_confirm.write(
orders_to_confirm._prepare_confirmation_values()
)
# Remove unwanted context
context = self._context.copy()
context.pop('default_name', None)
orders_to_confirm.with_context(context)._action_confirm()
user = orders_to_confirm[:1].create_uid
if user and user.sudo().has_group('sale.group_auto_done_setting'):
orders_to_confirm.action_lock()
if self.env.context.get('send_email'):
orders_to_confirm._send_order_confirmation_mail()
return True

24
auto_save_restrict/static/description/index.html

@ -171,7 +171,29 @@
>Email Us</span
>
</a>
<a href="skype:cybroopenerp?chat"
target="_blank"
style="
background-color: #7f289b;
font-family: Montserrat;
display: inline-block;
padding: 7px 33px;
border: 1px solid #7f289b;
border-radius: 35px;
text-decoration: none;
"
class="mx-1 mb-2 deep-1 deep_hover">
<img
class="img"
style="width: 24px"
src="./assets/icons/skype-fill.svg"
/>
<span
class="pl-2"
style="color: #fff; font-size: 16px; vertical-align: middle"
>Skype Us</span
>
</a>
</div>
<div class="d-flex justify-content-center mt-2">
<img src="./assets/screenshots/GIF.gif"

Loading…
Cancel
Save