forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Sale Confirmed in Background', | ||
'version': '10.0.1.0.0', | ||
'author': 'Camptocamp', | ||
'license': 'AGPL-3', | ||
'category': 'Sales', | ||
'depends': [ | ||
'sale', | ||
'queue_job', | ||
'web_notify', | ||
'sale_exception', | ||
], | ||
'website': 'https://www.camptocamp.com', | ||
'data': [ | ||
'views/sale_order_views.xml', | ||
], | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_confirm_background | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 10.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2018-06-28 06:18+0000\n" | ||
"PO-Revision-Date: 2018-06-28 06:18+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: sale_confirm_background | ||
#: model:ir.ui.view,arch_db:sale_confirm_background.view_order_background_form | ||
msgid "Cancel" | ||
msgstr "Annuler" | ||
|
||
#. module: sale_confirm_background | ||
#: code:addons/sale_confirm_background/models/sale_order.py:48 | ||
#, python-format | ||
msgid "Confirmation of sales order %s" | ||
msgstr "Confirmation de la commande %s" | ||
|
||
#. module: sale_confirm_background | ||
#: code:addons/sale_confirm_background/models/sale_order.py:30 | ||
#, python-format | ||
msgid "Order %s is now confirmed." | ||
msgstr "La commande %s est maintenant confirmée." | ||
|
||
#. module: sale_confirm_background | ||
#: code:addons/sale_confirm_background/models/sale_order.py:45 | ||
#, python-format | ||
msgid "Order %s will be confirmed in background." | ||
msgstr "La commande %s va être confirmée en arrière-plan." | ||
|
||
#. module: sale_confirm_background | ||
#: model:ir.model,name:sale_confirm_background.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "Commandes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_confirm_background | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 10.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2018-06-28 06:18+0000\n" | ||
"PO-Revision-Date: 2018-06-28 06:18+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: sale_confirm_background | ||
#: model:ir.ui.view,arch_db:sale_confirm_background.view_order_background_form | ||
msgid "Cancel" | ||
msgstr "" | ||
|
||
#. module: sale_confirm_background | ||
#: code:addons/sale_confirm_background/models/sale_order.py:48 | ||
#, python-format | ||
msgid "Confirmation of sales order %s" | ||
msgstr "" | ||
|
||
#. module: sale_confirm_background | ||
#: code:addons/sale_confirm_background/models/sale_order.py:30 | ||
#, python-format | ||
msgid "Order %s is now confirmed." | ||
msgstr "" | ||
|
||
#. module: sale_confirm_background | ||
#: code:addons/sale_confirm_background/models/sale_order.py:45 | ||
#, python-format | ||
msgid "Order %s will be confirmed in background." | ||
msgstr "" | ||
|
||
#. module: sale_confirm_background | ||
#: model:ir.model,name:sale_confirm_background.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.addons.queue_job.job import job | ||
|
||
|
||
class Sale(models.Model): | ||
_inherit = 'sale.order' | ||
|
||
state = fields.Selection( | ||
selection_add=[('confirm_background', 'Confirm in Background')] | ||
) | ||
|
||
@job(default_channel='root.background.sale_confirm') | ||
@api.multi | ||
def confirm_in_background(self, notify=True): | ||
"""Confirm sales order in background""" | ||
self.ensure_one() | ||
if self.state != 'confirm_background': | ||
return | ||
self.action_confirm() | ||
if notify: | ||
action = self.env.ref('sale.action_orders').read()[0] | ||
action.update({ | ||
'res_id': self.id, | ||
'views': [(False, 'form')], | ||
}) | ||
self.env.user.notify_info( | ||
_('Order %s is now confirmed.') % self.name, | ||
sticky=True, | ||
action=action, | ||
) | ||
|
||
def action_confirm_background(self): | ||
# compatibility with sale_exception | ||
# we want to raise interactively, not in background | ||
if self.detect_exceptions(): | ||
return self._popup_exceptions() | ||
self.write({ | ||
'state': 'confirm_background', | ||
'confirmation_date': fields.Datetime.now(), | ||
}) | ||
for order in self: | ||
self.env.user.notify_info( | ||
_('Order %s will be confirmed in background.') % order.name, | ||
) | ||
order.with_delay( | ||
description=_( | ||
'Confirmation of sales order %s' | ||
) % order.name, | ||
).confirm_in_background(notify=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="view_order_background_form" model="ir.ui.view"> | ||
<field name="name">sale.order.background.form</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form"/> | ||
<field name="priority">900</field> | ||
<field name="arch" type="xml"> | ||
<button name="action_cancel" position="after"> | ||
<button name="action_cancel" states="confirm_background" type="object" string="Cancel"/> | ||
</button> | ||
<button name="action_confirm" states="sent" position="attributes"> | ||
<attribute name="name">action_confirm_background</attribute> | ||
</button> | ||
<button name="action_confirm" states="draft" position="attributes"> | ||
<attribute name="name">action_confirm_background</attribute> | ||
</button> | ||
</field> | ||
</record> | ||
|
||
</odoo> |