Browse Source

ADD pos_supplierinfo_search

pull/516/head
eLBati 4 years ago
parent
commit
94a633e39b
  1. 1
      pos_supplierinfo_search/__init__.py
  2. 22
      pos_supplierinfo_search/__manifest__.py
  3. 1
      pos_supplierinfo_search/models/__init__.py
  4. 23
      pos_supplierinfo_search/models/product.py
  5. 1
      pos_supplierinfo_search/readme/CONTRIBUTORS.rst
  6. 1
      pos_supplierinfo_search/readme/DESCRIPTION.rst
  7. 1
      pos_supplierinfo_search/readme/USAGE.rst
  8. 30
      pos_supplierinfo_search/static/src/js/db.js
  9. 10
      pos_supplierinfo_search/views/assets.xml
  10. 1
      setup/pos_supplierinfo_search/odoo/addons/pos_supplierinfo_search
  11. 6
      setup/pos_supplierinfo_search/setup.py

1
pos_supplierinfo_search/__init__.py

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

22
pos_supplierinfo_search/__manifest__.py

@ -0,0 +1,22 @@
# Copyright 2020 Lorenzo Battistini @ TAKOBI
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "Point of sale - Search products by supplier",
"summary": "Search products by supplier data",
"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": "LGPL-3",
"application": False,
"installable": True,
"auto_install": False,
"depends": [
"point_of_sale",
],
"data": [
"views/assets.xml",
],
}

1
pos_supplierinfo_search/models/__init__.py

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

23
pos_supplierinfo_search/models/product.py

@ -0,0 +1,23 @@
import json
from odoo import models, fields, api
class ProductTemplate(models.Model):
_inherit = 'product.template'
# technical field used in POS frontend
supplier_data_json = fields.Char(
"Supplier data dict", readonly=True,
compute="_compute_supplier_data_json")
@api.multi
def _compute_supplier_data_json(self):
for t in self:
res = []
for s in t.seller_ids:
res.append({
'supplier_name': s.name.display_name,
'supplier_product_code': s.product_code or '',
'supplier_product_name': s.product_name or '',
})
t.supplier_data_json = json.dumps(res)

1
pos_supplierinfo_search/readme/CONTRIBUTORS.rst

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

1
pos_supplierinfo_search/readme/DESCRIPTION.rst

@ -0,0 +1 @@
In point of sale interface, allow to search products by supplier name, supplier product code or supplier product name.

1
pos_supplierinfo_search/readme/USAGE.rst

@ -0,0 +1 @@
In point of sale interface, just fill the "search products" box with some supplier data.

30
pos_supplierinfo_search/static/src/js/db.js

@ -0,0 +1,30 @@
odoo.define('pos_supplierinfo_search.db', function (require) {
"use strict";
var PosDB = require('point_of_sale.DB');
var models = require('point_of_sale.models');
models.load_fields("product.product", ["supplier_data_json"]);
PosDB.include({
_product_search_string: function(product){
var res = this._super(product).replace('\n', '');
var supplier_data_list = JSON.parse(product.supplier_data_json);
for(var i = 0, len = supplier_data_list.length; i < len; i++){
var supplier_data = supplier_data_list[i];
if (supplier_data.supplier_name) {
res += '|' + supplier_data.supplier_name.replace(/:/g,'');
}
if (supplier_data.supplier_product_code) {
res += '|' + supplier_data.supplier_product_code.replace(/:/g,'');
}
if (supplier_data.supplier_product_name) {
res += '|' + supplier_data.supplier_product_name.replace(/:/g,'');
}
}
res += '\n'
return res;
},
});
});

10
pos_supplierinfo_search/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_supplierinfo_search/static/src/js/db.js"/>
</xpath>
</template>
</odoo>

1
setup/pos_supplierinfo_search/odoo/addons/pos_supplierinfo_search

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

6
setup/pos_supplierinfo_search/setup.py

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