Browse Source

Merge PR #511 into 12.0

Signed-off-by legalsylvain
pull/514/head
OCA-git-bot 4 years ago
parent
commit
29df0e1b9f
  1. 1
      pos_multi_ean/__init__.py
  2. 25
      pos_multi_ean/__manifest__.py
  3. 1
      pos_multi_ean/models/__init__.py
  4. 17
      pos_multi_ean/models/product.py
  5. 1
      pos_multi_ean/readme/CONFIGURE.rst
  6. 1
      pos_multi_ean/readme/CONTRIBUTORS.rst
  7. 1
      pos_multi_ean/readme/DESCRIPTION.rst
  8. 1
      pos_multi_ean/readme/USAGE.rst
  9. 29
      pos_multi_ean/static/src/js/db.js
  10. 10
      pos_multi_ean/views/assets.xml
  11. 1
      setup/pos_multi_ean/odoo/addons/pos_multi_ean
  12. 6
      setup/pos_multi_ean/setup.py

1
pos_multi_ean/__init__.py

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

25
pos_multi_ean/__manifest__.py

@ -0,0 +1,25 @@
# Copyright 2020 Lorenzo Battistini @ TAKOBI
# License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "Point of sale - Multi EAN support",
"summary": "Search products by multiple EAN",
"version": "12.0.1.0.0",
"development_status": "Beta",
"category": "Point Of Sale",
"website": "https://github.com/OCA/pos",
"author": "TAKOBI, Odoo Community Association (OCA)",
"maintainers": ["eLBati"],
"license": "AGPL-3",
"application": False,
"installable": True,
"auto_install": True,
"depends": [
"product_multi_ean",
"point_of_sale",
],
"data": [
"views/assets.xml",
],
"demo": [
],
}

1
pos_multi_ean/models/__init__.py

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

17
pos_multi_ean/models/product.py

@ -0,0 +1,17 @@
import json
from odoo import models, fields, api
class Product(models.Model):
_inherit = 'product.product'
# technical field used in POS frontend
multi_ean_json = fields.Char(
"Multi EAN list", readonly=True,
compute="_compute_multi_ean_json")
@api.multi
def _compute_multi_ean_json(self):
for p in self:
multi_ean_json = [x for x in p.mapped('ean13_ids.name') if x]
p.multi_ean_json = json.dumps(multi_ean_json)

1
pos_multi_ean/readme/CONFIGURE.rst

@ -0,0 +1 @@
Open product (variant) form and add EAN13 lines.

1
pos_multi_ean/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Lorenzo Battistini (https://takobi.online)

1
pos_multi_ean/readme/DESCRIPTION.rst

@ -0,0 +1 @@
In point of sale interface, allow to search products by multiple EAN (defined by product_multi_ean module) while scanning product barcode to add it to order.

1
pos_multi_ean/readme/USAGE.rst

@ -0,0 +1 @@
In point of sale interface, just scan a barcode previously added to EAN13 list. The product will be added to order.

29
pos_multi_ean/static/src/js/db.js

@ -0,0 +1,29 @@
odoo.define('pos_multi_ean.db', function (require) {
"use strict";
var PosDB = require('point_of_sale.DB');
var models = require('point_of_sale.models');
models.load_fields("product.product", ["multi_ean_json"]);
PosDB.include({
add_products: function(products) {
var res = this._super(products);
if(!products instanceof Array){
products = [products];
}
for(var i = 0, len = products.length; i < len; i++){
var product = products[i];
var multi_ean_list = JSON.parse(product.multi_ean_json);
for(var j = 0, jlen = multi_ean_list.length; j < jlen; j++){
var ean = multi_ean_list[j];
this.product_by_barcode[ean] = product;
}
}
return res;
},
});
});

10
pos_multi_ean/views/assets.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_multi_ean/static/src/js/db.js"/>
</xpath>
</template>
</odoo>

1
setup/pos_multi_ean/odoo/addons/pos_multi_ean

@ -0,0 +1 @@
../../../../pos_multi_ean

6
setup/pos_multi_ean/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading…
Cancel
Save