Browse Source

[ADD] Add caisse ID config + manage in pos

12-V2.0
Juliana 4 years ago
parent
commit
f26c7b757e
  1. 2
      models/pos_transaction.py
  2. 18
      static/src/js/container.js
  3. 39
      static/src/js/models_and_db.js
  4. 16
      views/pos_config_views.xml

2
models/pos_transaction.py

@ -14,7 +14,7 @@ class PosTransaction(models.Model):
_description = 'Table des Transactions' _description = 'Table des Transactions'
name = fields.Char('Ref Produit') name = fields.Char('Ref Produit')
balance_id = fields.Char('Id de la balance')
balance_id = fields.Char('Id de la balance/caisse')
qrcode = fields.Char("QRCode") qrcode = fields.Char("QRCode")
ean13 = fields.Char('EAN13 Poids Produits', size=13) ean13 = fields.Char('EAN13 Poids Produits', size=13)
ean13_verif = fields.Char('EAN13 Vérification Poids', size=13) ean13_verif = fields.Char('EAN13 Vérification Poids', size=13)

18
static/src/js/container.js

@ -30,7 +30,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
show: function(){ show: function(){
var self = this; var self = this;
if (this.pos.config.balance_id) {
if (this.pos.config.is_balance_free) {
var queue = this.pos.proxy_queue; var queue = this.pos.proxy_queue;
var container = this.gui.get_current_screen_param('container'); var container = this.gui.get_current_screen_param('container');
@ -398,7 +398,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
'name':'balancescale', 'name':'balancescale',
'widget': BalanceScaleScreenWidget, 'widget': BalanceScaleScreenWidget,
'condition': function(){ 'condition': function(){
return this.pos.config.balance_id;
return this.pos.config.is_balance_free;
}, },
}); });
@ -642,7 +642,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
'name':'products-balance', 'name':'products-balance',
'widget': ProductBalanceScreenWidget, 'widget': ProductBalanceScreenWidget,
'condition': function(){ 'condition': function(){
return this.pos.config.balance_id;
return this.pos.config.is_balance_free;
}, },
}); });
@ -765,7 +765,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
'name':'balancecontainerscale', 'name':'balancecontainerscale',
'widget': BalanceContainerScaleScreenWidget, 'widget': BalanceContainerScaleScreenWidget,
'condition': function(){ 'condition': function(){
return this.pos.config.balance_id;
return this.pos.config.is_balance_free;
}, },
}); });
@ -820,7 +820,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
'name': 'presentation', 'name': 'presentation',
'widget': PresentationScreenWidget, 'widget': PresentationScreenWidget,
'condition': function(){ 'condition': function(){
return this.pos.config.balance_id;
return this.pos.config.is_balance_free;
}, },
}); });
@ -928,7 +928,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
'name': 'confirmation', 'name': 'confirmation',
'widget': ConfirmationScreen, 'widget': ConfirmationScreen,
'condition': function(){ 'condition': function(){
return this.pos.config.balance_id;
return this.pos.config.is_balance_free;
}, },
}); });
@ -936,14 +936,14 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
chrome.Chrome.include({ chrome.Chrome.include({
build_widgets: function(){ build_widgets: function(){
this._super(); this._super();
if (this.pos.config.balance_id) {
if (this.pos.config.is_balance_free) {
this.gui.set_startup_screen('presentation'); this.gui.set_startup_screen('presentation');
} }
}, },
build_chrome: function() { build_chrome: function() {
this._super(); this._super();
if (this.pos.config.balance_id) {
if (this.pos.config.is_balance_free) {
this.$('.pos-topheader').addClass('oe_hidden'); this.$('.pos-topheader').addClass('oe_hidden');
} }
else { else {
@ -974,7 +974,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
renderElement: function(){ renderElement: function(){
var self = this; var self = this;
this._super(); this._super();
if (this.pos.config.balance_id) {
if (this.pos.config.is_balance_free) {
if (this.pos.get_order()) { if (this.pos.get_order()) {
this.$el.removeClass('oe_invisible'); this.$el.removeClass('oe_invisible');
} else { } else {

39
static/src/js/models_and_db.js

@ -145,13 +145,20 @@ odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (requi
} }
}, },
// returns the header text from config
// returns the id of balance/caisse from config
get_balance_id: function(){ get_balance_id: function(){
if (this.config.balance_id) { if (this.config.balance_id) {
return this.config.balance_id; return this.config.balance_id;
} }
}, },
// returns if the pos is balance from config
get_is_balance_free: function(){
if (this.config.is_balance_free) {
return this.config.is_balance_free;
}
},
get_is_comptoir: function(){ get_is_comptoir: function(){
if (this.config.is_comptoir) { if (this.config.is_comptoir) {
return this.config.is_comptoir; return this.config.is_comptoir;
@ -264,6 +271,36 @@ odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (requi
}); });
// Add container to order line
models.Orderline = models.Orderline.extend({
export_as_JSON: function(){
var pack_lot_ids = [];
if (this.has_product_lot){
this.pack_lot_lines.each(_.bind( function(item) {
return pack_lot_ids.push([0, 0, item.export_as_JSON()]);
}, this));
}
return {
qty: this.get_quantity(),
price_unit: this.get_unit_price(),
price_subtotal: this.get_price_without_tax(),
price_subtotal_incl: this.get_price_with_tax(),
discount: this.get_discount(),
product_id: this.get_product().id,
tax_ids: [[6, false, _.map(this.get_applicable_taxes(), function(tax){ return tax.id; })]],
id: this.id,
pack_lot_ids: pack_lot_ids,
//custom starts here
tare: this.get_tare(),
container_id: this.get_container() ? this.get_container().id : null,
container_barcode: this.get_container() ? this.get_container().barcode : null,
container_weight: this.get_container() ? this.get_container().weight : null,
caisse_id: this.pos.config.balance_id,
};
},
}),
models.load_models({ models.load_models({
model: 'pos.transaction', model: 'pos.transaction',
fields: ['product_id', 'name', 'balance_id', 'ean13', 'write_date', 'container_ean13', 'weight_net', 'price_product', 'price_net', 'weight_tare'], fields: ['product_id', 'name', 'balance_id', 'ean13', 'write_date', 'container_ean13', 'weight_net', 'price_product', 'price_net', 'weight_tare'],

16
views/pos_config_views.xml

@ -8,6 +8,22 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<div id="posbox_reference" position="inside"> <div id="posbox_reference" position="inside">
<div id="caisse" class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Caisse ID</span>
<div class="text-muted">
Définition de l'ID Caisse pour l'API
</div>
<div class="content-group" attrs="{'invisible': [('is_balance_free', '!=', False)]}">
<div class="row mt16">
<label for="balance_id" class="col-lg-3 o_light_label"/>
<field name="balance_id"/>
</div>
</div>
</div>
</div>
<div id="balance_free" class="col-12 col-lg-6 o_setting_box"> <div id="balance_free" class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane"> <div class="o_setting_left_pane">
<field name="is_balance_free"/> <field name="is_balance_free"/>

Loading…
Cancel
Save