Browse Source
Merge pull request #227 from akretion/10.0-add-pos_backend_partner
Merge pull request #227 from akretion/10.0-add-pos_backend_partner
Add mobule pos_backend_partnerpull/233/head
Eric @ Elico Corp
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 305 additions and 0 deletions
-
1oca_dependencies.txt
-
96pos_backend_partner/README.rst
-
2pos_backend_partner/__init__.py
-
23pos_backend_partner/__manifest__.py
-
2pos_backend_partner/models/__init__.py
-
25pos_backend_partner/models/partner.py
-
BINpos_backend_partner/static/description/pos_backend_partner_1.png
-
BINpos_backend_partner/static/description/pos_backend_partner_2.png
-
BINpos_backend_partner/static/description/pos_backend_partner_3.png
-
7pos_backend_partner/static/src/css/pos_backend_partner.css
-
17pos_backend_partner/static/src/js/back_partner.js
-
89pos_backend_partner/static/src/js/pos_partner.js
-
18pos_backend_partner/views/assets.xml
-
25pos_backend_partner/views/backend_partner.xml
@ -0,0 +1 @@ |
|||
pos https://github.com/akretion/pos.git 10.0-add-pos_backend_communication |
@ -0,0 +1,96 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png |
|||
:target: https://www.gnu.org/licenses/agpl |
|||
:alt: License: AGPL-3 |
|||
|
|||
|
|||
=================== |
|||
POS Backend Partner |
|||
=================== |
|||
|
|||
Choose a POS customer from the backend. |
|||
|
|||
|
|||
- Replace customer selection screen in POS by a backend view. |
|||
- Perf improvement : Full customer list is not downloaded anymore by the POS at startup. |
|||
- Benefit from the backend features: advanced search, easy to extend views, etc. |
|||
|
|||
|
|||
.. figure:: ./static/description/pos_backend_partner_1.png |
|||
:width: 800px |
|||
|
|||
|
|||
.. figure:: ./static/description/pos_backend_partner_2.png |
|||
:width: 800px |
|||
|
|||
|
|||
.. figure:: ./static/description/pos_backend_partner_3.png |
|||
:width: 800px |
|||
|
|||
|
|||
|
|||
Warning about offline mode |
|||
-------------------------- |
|||
|
|||
Due to design of this module, you can't choose a **named customer** while offline but you |
|||
can still register orders with **anonymous** user. |
|||
|
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
On each client's browser, during the first run, the permission for opening popup is prompted, it should be allowed. |
|||
|
|||
|
|||
Known issues / Roadmap |
|||
====================== |
|||
|
|||
* See module pos_backend_communication (OCA/POS) |
|||
* css glitch: previously clicked buttons are not reset to initial value |
|||
|
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues |
|||
<https://github.com/OCA/pos/issues>`_. In case of trouble, please |
|||
check there if your issue has already been reported. If you spotted it first, |
|||
help us smash it by providing detailed and welcomed feedback. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Images |
|||
------ |
|||
|
|||
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_. |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Raphaël Reverdy <raphael.reverdy@akretion.com> http://akretion.com |
|||
|
|||
Do not contact contributors directly about support or help with technical issues. |
|||
|
|||
Funders |
|||
------- |
|||
|
|||
The development of this module has been financially supported by: |
|||
|
|||
* Akretion |
|||
|
|||
|
|||
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 https://odoo-community.org. |
|||
|
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import models |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2017 Akretion (http://www.akretion.com). |
|||
# @author Raphaël Reverdy <raphael.reverdy@akretion.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
{ |
|||
"name": "POS Backend Customer", |
|||
"summary": "Choose point of sale customers in backend", |
|||
"version": "10.0.1.0.0", |
|||
"category": "Point of sale", |
|||
"website": "www.akretion.com", |
|||
'author': "Akretion,Odoo Community Association (OCA)", |
|||
"license": "AGPL-3", |
|||
"application": False, |
|||
'installable': True, |
|||
"depends": [ |
|||
"pos_backend_communication", |
|||
], |
|||
"data": [ |
|||
'views/assets.xml', |
|||
'views/backend_partner.xml', |
|||
], |
|||
} |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import partner |
@ -0,0 +1,25 @@ |
|||
# coding: utf-8 |
|||
# Copyright 2017 Akretion (http://www.akretion.com). |
|||
# @author Raphaël Reverdy <raphael.reverdy@akretion.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openerp import models, api |
|||
|
|||
|
|||
class Partner(models.Model): |
|||
_inherit = "res.partner" |
|||
|
|||
@api.multi |
|||
def select_in_pos_current_order(self): |
|||
"""Set point of sale customer to this partner. |
|||
|
|||
Action called from view with self.id = a res.partner. |
|||
""" |
|||
return { |
|||
'type': 'ir.actions.act_tell_pos', |
|||
'payload': { |
|||
'type': 'partner.partner_selected', |
|||
'partner_id': self.id, |
|||
'name': self.name, |
|||
}, |
|||
} |
After Width: 2048 | Height: 1536 | Size: 197 KiB |
After Width: 2048 | Height: 1536 | Size: 209 KiB |
After Width: 2048 | Height: 1536 | Size: 196 KiB |
@ -0,0 +1,7 @@ |
|||
td[data-field="select_in_pos_current_order"] { |
|||
display:none; |
|||
} |
|||
|
|||
.pos_backend_communication td[data-field="select_in_pos_current_order"] { |
|||
display:block; |
|||
} |
@ -0,0 +1,17 @@ |
|||
'use strict'; |
|||
odoo.define('pos_backend_partner.partner_back', function (require) { |
|||
var translation = require('web.translation'); |
|||
var _t = translation._t; |
|||
|
|||
var tools = require('pos_backend_communication.back'); |
|||
|
|||
if (tools.is_tied_to_pos()) { |
|||
tools.callbacks['partner.choose'] = function() { |
|||
//get focus with alert
|
|||
//TODO: replace with notifications
|
|||
alert(_t('Choose a customer')); |
|||
}; |
|||
//tell the POS we are ready to receive
|
|||
tools.sendMessage({type: 'partner.ready'}); |
|||
} |
|||
}); |
@ -0,0 +1,89 @@ |
|||
'use strict'; |
|||
|
|||
odoo.define('pos_backend_partner.partner_pos', function (require) { |
|||
var tools = require('pos_backend_communication.tools'); |
|||
var session = require('web.session'); |
|||
var ProductScreenWidget = require('point_of_sale.screens'); |
|||
var translation = require('web.translation'); |
|||
var _t = translation._t; |
|||
var action_url = null; |
|||
var pos_instance = null; |
|||
|
|||
function set_client(message) { |
|||
var data = message.data; |
|||
var partner_info = { |
|||
'id': parseInt(data.id, 10), |
|||
'name': data.name |
|||
}; |
|||
pos_instance.get('selectedOrder').set_client(partner_info); |
|||
alert(_t('Customer set')); //try to get the focus back
|
|||
} |
|||
|
|||
function open_backend(message) { |
|||
console.log('open backend partner'); |
|||
//lookup action_id
|
|||
action_url = action_url || session.rpc( |
|||
'/web/action/load', { "action_id":"pos_backend_partner.action_select_partner_pos"}) |
|||
.then(function (e) { return e.id; }); |
|||
|
|||
action_url.then(function (action_id) { |
|||
var url = "/web#view_type=list&model=res.partner&action=" + action_id; |
|||
var msg = {'type': 'partner.choose'}; |
|||
tools.open_page(url, msg, 'partner'); |
|||
}); |
|||
} |
|||
|
|||
// Bind customer button in main screen
|
|||
ProductScreenWidget.ActionpadWidget.include({ |
|||
init: function(parent, options) { |
|||
this._super(parent, options); |
|||
pos_instance = this.pos; |
|||
}, |
|||
renderElement: function() { |
|||
var self = this; |
|||
this._super(); |
|||
this.$('.set-customer').unbind('click'); |
|||
this.$('.set-customer').click(function(){ |
|||
open_backend(); |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
// Bind customer button in payement screen
|
|||
ProductScreenWidget.PaymentScreenWidget.include({ |
|||
init: function(parent, options) { |
|||
this._super(parent, options); |
|||
pos_instance = this.pos; |
|||
}, |
|||
click_set_customer: function() { |
|||
open_backend(); |
|||
} |
|||
}); |
|||
|
|||
tools.callbacks['partner.partner_selected'] = set_client; |
|||
|
|||
return { |
|||
callbacks: tools.callbacks |
|||
}; |
|||
}); |
|||
|
|||
odoo.define('pos_backend_partner.prevent_model_load', function (require) { |
|||
// Prevent res.partner to be loaded at startup of the POS
|
|||
// we load partners from the back office
|
|||
|
|||
//huge perf improvement server side AND client side AND network side
|
|||
// we don't need it since the client is picked from the backoffice
|
|||
var pos_models = require('point_of_sale.models'); |
|||
var partnerModelId = null; |
|||
pos_models.PosModel.prototype.models.some(function (m, idx) { |
|||
if (m.model !== "res.partner") |
|||
return false; |
|||
partnerModelId = idx; //got her !
|
|||
return true; //exit early
|
|||
}); |
|||
if (partnerModelId) { |
|||
pos_models.PosModel.prototype.models.splice(partnerModelId, 1); |
|||
//remove the model without changing the reference to the array
|
|||
} |
|||
}); |
|||
|
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<template id="assets" name="pos partner" inherit_id="point_of_sale.assets"> |
|||
<xpath expr="." position="inside"> |
|||
<script type="text/javascript" src="/pos_backend_partner/static/src/js/pos_partner.js"></script> |
|||
</xpath> |
|||
</template> |
|||
|
|||
<template id="assets_backend" name="back partner " inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> <!-- both back and POS --> |
|||
<script type="text/javascript" src="/pos_backend_partner/static/src/js/back_partner.js"></script> |
|||
|
|||
<link rel="stylesheet" href="/pos_backend_partner/static/src/css/pos_backend_partner.css"/> |
|||
|
|||
</xpath> |
|||
</template> |
|||
|
|||
</odoo> |
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="view_partner_tree" model="ir.ui.view"> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="base.view_partner_tree"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="display_name" position="before"> |
|||
<button string="Choose" |
|||
type="object" name="select_in_pos_current_order" |
|||
help="Select as customer in point of sale"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_select_partner_pos" model="ir.actions.act_window"> |
|||
<field name="name">Client</field> |
|||
<field name="type">ir.actions.act_window</field> |
|||
<field name="res_model">res.partner</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="domain">[('customer', '=', True)]</field> |
|||
<field name="context">{}</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue