Browse Source
Merge pull request #130 from EBII/10.0-mig-sms_send_picking
Merge pull request #130 from EBII/10.0-mig-sms_send_picking
10.0 mig sms send pickingpull/157/head
Alexis de Lattre
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 253 additions and 0 deletions
-
61sms_send_picking/README.rst
-
5sms_send_picking/__init__.py
-
21sms_send_picking/__manifest__.py
-
16sms_send_picking/data/cron.xml
-
33sms_send_picking/i18n/fr.po
-
5sms_send_picking/models/__init__.py
-
62sms_send_picking/models/stock.py
-
1sms_send_picking/tests/__init__.py
-
49sms_send_picking/tests/test_sms_send_picking.py
@ -0,0 +1,61 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
================= |
||||
|
SMS send picking |
||||
|
================= |
||||
|
|
||||
|
This module provides a cron and a method to automaticly sending a SMS when a |
||||
|
picking delivery is ready to transfert. |
||||
|
|
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
|
||||
|
You can configure the verification time in the scheduled action. |
||||
|
|
||||
|
Usage |
||||
|
===== |
||||
|
|
||||
|
To use this module, you need to: |
||||
|
|
||||
|
* have a gateway correctly configured with keychain account |
||||
|
* put some picking delivery in ready to transfert state |
||||
|
|
||||
|
For further information, please visit: |
||||
|
|
||||
|
* https://www.odoo.com/forum/help-1 |
||||
|
|
||||
|
|
||||
|
Bug Tracker |
||||
|
=========== |
||||
|
|
||||
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector-telephony/issues>`_. |
||||
|
In case of trouble, please check there if your issue has already been reported. |
||||
|
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback |
||||
|
|
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Valentin Chemiere <valentin.chemiere@akretion.com> |
||||
|
* MonsieurB <monsieurb@saaslys.com> |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: https://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: https://odoo-community.org |
||||
|
|
||||
|
This module is maintained by the OCA. |
||||
|
|
||||
|
OCA, or the Odoo Community Association, is a nonprofit organization whose |
||||
|
mission is to support the collaborative development of Odoo features and |
||||
|
promote its widespread use. |
||||
|
|
||||
|
To contribute to this module, please visit http://odoo-community.org. |
||||
|
|
@ -0,0 +1,5 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2015 Valentin CHEMIERE <valentin.chemiere@akretion.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from . import models |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2015 Valentin CHEMIERE <valentin.chemiere@akretion.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
{ |
||||
|
'name': 'Sms Send Picking', |
||||
|
'version': '10.0.1.0.0', |
||||
|
'author': 'Akretion, Odoo Community Association (OCA)', |
||||
|
'website': 'www.akretion.com', |
||||
|
'license': 'AGPL-3', |
||||
|
'category': 'Phone', |
||||
|
'depends': [ |
||||
|
'stock', |
||||
|
'base_sms_client', |
||||
|
], |
||||
|
'data': [ |
||||
|
'data/cron.xml' |
||||
|
], |
||||
|
'installable': True, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<openerp> |
||||
|
<data noupdate="1"> |
||||
|
<record id="ir_cron_send_sms_picking_action" model="ir.cron"> |
||||
|
<field name="name">Auto Send SMS Picking Ready</field> |
||||
|
<field name="interval_number">5</field> |
||||
|
<field name="interval_type">minutes</field> |
||||
|
<field name="numbercall">-1</field> |
||||
|
<field name="doall">False</field> |
||||
|
<field name="model">stock.picking</field> |
||||
|
<field name="function">_cron_send_picking_availability_by_sms</field> |
||||
|
<field name="args">()</field> |
||||
|
<field name="active" eval="False"/> |
||||
|
</record> |
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,33 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * sms_send_picking |
||||
|
# |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 8.0\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2015-09-04 13:28+0000\n" |
||||
|
"PO-Revision-Date: 2015-09-04 13:28+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: sms_send_picking |
||||
|
#: model:ir.model,name:sms_send_picking.model_stock_picking |
||||
|
msgid "Picking List" |
||||
|
msgstr "Opération de manutention" |
||||
|
|
||||
|
#. module: sms_send_picking |
||||
|
#: field:stock.picking,sms_sent:0 |
||||
|
msgid "Sms sent" |
||||
|
msgstr "Sms envoyé" |
||||
|
|
||||
|
#. module: sms_send_picking |
||||
|
#: code:addons/sms_send_picking/stock.py:44 |
||||
|
#, python-format |
||||
|
msgid "Your picking %s is ready to transfert" |
||||
|
msgstr "Votre commande %s est prète a être retiré" |
||||
|
|
@ -0,0 +1,5 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2015 Valentin CHEMIERE <valentin.chemiere@akretion.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from . import stock |
@ -0,0 +1,62 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2015 Valentin CHEMIERE <valentin.chemiere@akretion.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from odoo import api, models, fields |
||||
|
from odoo.tools.translate import _ |
||||
|
import logging |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
class StockPicking(models.Model): |
||||
|
_inherit = 'stock.picking' |
||||
|
|
||||
|
availability_sent_by_sms = fields.Boolean(default=False) |
||||
|
|
||||
|
# TODO use a templating instead |
||||
|
@api.multi |
||||
|
def _prepare_availability_by_sms_notification(self): |
||||
|
self.ensure_one() |
||||
|
gateway = self.env['sms.gateway'].search([ |
||||
|
('default_gateway', '=', True)], limit=1) |
||||
|
return { |
||||
|
'gateway_id': gateway.id, |
||||
|
'message': _('Your picking %s is ready to transfer.') % self.name, |
||||
|
'mobile': self.partner_id.mobile, |
||||
|
'partner_id': self.partner_id.id, |
||||
|
'state': 'draft', |
||||
|
'validity': gateway.validity, |
||||
|
'classes': gateway.classes, |
||||
|
'deferred': gateway.deferred, |
||||
|
'priority': gateway.priority, |
||||
|
'coding': gateway.coding, |
||||
|
'nostop': gateway.nostop, |
||||
|
'company_id': self.company_id.id, |
||||
|
} |
||||
|
|
||||
|
@api.model |
||||
|
def _get_send_picking_availability_by_sms_domain(self): |
||||
|
return [ |
||||
|
('state', '=', 'assigned'), # assigned = available |
||||
|
('availability_sent_by_sms', '=', False), |
||||
|
('picking_type_id.code', '=', 'outgoing'), |
||||
|
] |
||||
|
|
||||
|
@api.model |
||||
|
def _cron_send_picking_availability_by_sms(self): |
||||
|
domain = self._get_send_picking_availability_by_sms_domain() |
||||
|
pickings = self.search(domain) |
||||
|
total = len(pickings) |
||||
|
for idx, picking in enumerate(pickings): |
||||
|
_logger.debug('Send Sms for picking %s, progress %s/%s', picking, |
||||
|
idx, total) |
||||
|
vals = picking._prepare_availability_by_sms_notification() |
||||
|
if not vals['mobile']: |
||||
|
_logger.warning( |
||||
|
_("SMS issue for picking %s : no mobile phone" |
||||
|
% picking.id)) |
||||
|
continue |
||||
|
self.env['sms.sms'].create(vals) |
||||
|
picking.write({'availability_sent_by_sms': True}) |
||||
|
picking._cr.commit() |
@ -0,0 +1 @@ |
|||||
|
from . import test_sms_send_picking |
@ -0,0 +1,49 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Akretion France |
||||
|
|
||||
|
from odoo.tests.common import TransactionCase |
||||
|
|
||||
|
|
||||
|
class TestSmsSendPicking(TransactionCase): |
||||
|
|
||||
|
def setUp(self): |
||||
|
super(TestSmsSendPicking, self).setUp() |
||||
|
self.partner = self.env['res.partner'].create({ |
||||
|
'name': 'test man', |
||||
|
'mobile': '336789123', |
||||
|
'email': 'testcustomer+3@test.com', |
||||
|
}) |
||||
|
self.product = self.env.ref('product.product_product_4') |
||||
|
self.picking_out = self.env['stock.picking'].create({ |
||||
|
'picking_type_id': self.ref('stock.picking_type_out'), |
||||
|
'location_id': self.env.ref('stock.stock_location_stock').id, |
||||
|
'location_dest_id': ( |
||||
|
self.env.ref('stock.stock_location_customers').id |
||||
|
), |
||||
|
'partner_id': self.partner.id |
||||
|
}) |
||||
|
self.env['stock.move'].create({ |
||||
|
'name': 'a move', |
||||
|
'product_id': self.product.id, |
||||
|
'product_uom_qty': 3.0, |
||||
|
'product_uom': self.product.uom_id.id, |
||||
|
'picking_id': self.picking_out.id, |
||||
|
'location_id': self.env.ref('stock.stock_location_stock').id, |
||||
|
'location_dest_id': ( |
||||
|
self.env.ref('stock.stock_location_customers').id |
||||
|
) |
||||
|
}) |
||||
|
self.picking_out.action_assign() |
||||
|
self.picking_out.force_assign() |
||||
|
|
||||
|
def test_availability_flag(self): |
||||
|
self.assertEqual(False, self.picking_out.availability_sent_by_sms) |
||||
|
self.picking_out._cron_send_picking_availability_by_sms() |
||||
|
self.assertEqual(True, self.picking_out.availability_sent_by_sms) |
||||
|
|
||||
|
def test_sms_created(self): |
||||
|
dom = [('message', 'ilike', |
||||
|
'Your picking %s %%' % self.picking_out.name)] |
||||
|
self.assertTrue(len(self.env['sms.sms'].search(dom)) == 0) |
||||
|
self.picking_out._cron_send_picking_availability_by_sms() |
||||
|
self.assertTrue(len(self.env['sms.sms'].search(dom)) == 1) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue