Skip to content

Commit

Permalink
[12.0][MIG] stock_barcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe authored and AdriaGForgeFlow committed Nov 6, 2019
1 parent b57e0a1 commit c567261
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 60 deletions.
14 changes: 9 additions & 5 deletions stock_barcodes/README.rst
Expand Up @@ -14,13 +14,13 @@ Stock Barcodes
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--barcode-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-barcode/tree/11.0/stock_barcodes
:target: https://github.com/OCA/stock-logistics-barcode/tree/12.0/stock_barcodes
:alt: OCA/stock-logistics-barcode
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-barcode-11-0/stock-logistics-barcode-11-0-stock_barcodes
:target: https://translation.odoo-community.org/projects/stock-logistics-barcode-12-0/stock-logistics-barcode-12-0-stock_barcodes
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/150/11.0
:target: https://runbot.odoo-community.org/runbot/150/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -144,7 +144,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-barcode/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 <https://github.com/OCA/stock-logistics-barcode/issues/new?body=module:%20stock_barcodes%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-barcode/issues/new?body=module:%20stock_barcodes%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -166,6 +166,10 @@ Contributors
* Carlos Dauden
* Pedro M. Baeza

* `Onestein <https://www.onestein.eu>`_:

* Andrea Stirpe

Maintainers
~~~~~~~~~~~

Expand All @@ -179,6 +183,6 @@ 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.

This module is part of the `OCA/stock-logistics-barcode <https://github.com/OCA/stock-logistics-barcode/tree/11.0/stock_barcodes>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-barcode <https://github.com/OCA/stock-logistics-barcode/tree/12.0/stock_barcodes>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
10 changes: 5 additions & 5 deletions stock_barcodes/__manifest__.py
Expand Up @@ -3,15 +3,15 @@
{
"name": "Stock Barcodes",
"summary": "It provides read barcode on stock operations.",
"version": "11.0.2.0.0",
"version": "12.0.1.0.0",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"website": "https://odoo-community.org/",
"website": "https://github.com/OCA/stock-logistics-barcode",
"license": "AGPL-3",
"category": "Extra Tools",
"depends": [
'barcodes',
'stock',
"barcodes",
"stock",
],
"data": [
'security/ir.model.access.csv',
Expand All @@ -23,5 +23,5 @@
'wizard/stock_barcodes_read_inventory_views.xml',
'wizard/stock_barcodes_read_picking_views.xml',
],
'installable': True,
"installable": True,
}
5 changes: 1 addition & 4 deletions stock_barcodes/models/stock_barcodes_read_log.py
Expand Up @@ -9,15 +9,14 @@ class StockBarcodesReadLog(models.Model):
_description = 'Log barcode scanner'
_order = 'id DESC'

name = fields.Char(string='barcode')
name = fields.Char(string='Barcode Scanned')
res_model_id = fields.Many2one(
comodel_name='ir.model',
index=True,
)
res_id = fields.Integer(index=True)
product_id = fields.Many2one(
comodel_name='product.product',
string='Product',
index=True,
)
lot_id = fields.Many2one(
Expand All @@ -26,11 +25,9 @@ class StockBarcodesReadLog(models.Model):
)
location_id = fields.Many2one(
comodel_name='stock.location',
string='Location',
)
packaging_id = fields.Many2one(
comodel_name='product.packaging',
string='Packaging',
)
packaging_qty = fields.Float(
string='Package Qty',
Expand Down
4 changes: 4 additions & 0 deletions stock_barcodes/readme/CONTRIBUTORS.rst
Expand Up @@ -4,3 +4,7 @@
* Sergio Teruel
* Carlos Dauden
* Pedro M. Baeza

* `Onestein <https://www.onestein.eu>`_:

* Andrea Stirpe
@@ -1,7 +1,7 @@
/* Copyright 2018-2019 Sergio Teruel <sergio.teruel@tecnativa.com>.
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */

odoo.define('stock_barcodes.FieldFloatNumericMode', function(require) {
odoo.define('stock_barcodes.FieldFloatNumericMode', function (require) {
'use strict';

var basic_fields = require('web.basic_fields');
Expand All @@ -23,6 +23,24 @@ odoo.define('stock_barcodes.FieldFloatNumericMode', function(require) {
return $input_numeric;
},
});

var FieldBarcodeBooleanToggle = basic_fields.BooleanToggle.extend({
/*
This is needed because, whenever we click the checkbox to enter data manually, the checkbox will be
focused causing that when we scan the barcode afterwards, it will not perform the python on_barcode_scanned
function.
*/
_onClick: function (event) {
this._super.apply(this, arguments);
$(this.el).find("input").blur()
},
});

field_registry.add('FieldFloatNumericMode', FieldFloatNumericMode);
return FieldFloatNumericMode;
field_registry.add('barcode_boolean_toggle', FieldBarcodeBooleanToggle);

return {
FieldFloatNumericMode: FieldFloatNumericMode,
FieldBarcodeBooleanToggle: FieldBarcodeBooleanToggle,
}
});
23 changes: 16 additions & 7 deletions stock_barcodes/static/src/js/stock_barcodes.js
@@ -1,7 +1,7 @@
/* Copyright 2018-2019 Sergio Teruel <sergio.teruel@tecnativa.com>.
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */

odoo.define('stock_barcodes.FormController', function(require) {
odoo.define('stock_barcodes.FormController', function (require) {
'use strict';

var FormController = require('web.FormController');
Expand All @@ -13,30 +13,39 @@ odoo.define('stock_barcodes.FormController', function(require) {
Set control focus to package_qty or product_qty directly after
scan a barcode for manual entry mode entries.
*/
this._super(barcode, target).then(function(){
this._super(barcode, target).then(function () {
var manual_entry_mode = self.$("div[name='manual_entry'] input").val();
if (manual_entry_mode){
if (manual_entry_mode) {
var packaging = self.$("div[name='packaging_id'] input").val();
if (packaging) {
self.$("input[name='packaging_qty']").focus();
} else {
self.$("input[name='product_qty']").focus();
};
};
}
}
});
},
renderButtons: function($node){
renderButtons: function ($node) {
/*
Hide save and discard buttons from wizard, for this form do
anything and confuse the user if he wants do a manual entry. All
extended models from wiz.stock.barcodes.read do not have this
buttons.
*/
this._super($node);
if (this.modelName.includes('wiz.stock.barcodes.read.')){
if (this.modelName.includes('wiz.stock.barcodes.read.')) {
this.$buttons.find('.o_form_buttons_edit')
.css({'display': 'none'});
}
},
canBeDiscarded: function (recordID) {
/*
Silent the warning that says that the record has been modified.
*/
if (!this.modelName.includes('wiz.stock.barcodes.read.')) {
return this._super.apply(this, arguments);
}
return $.when(false);
},
});
});
5 changes: 2 additions & 3 deletions stock_barcodes/tests/test_stock_barcodes_inventory.py
@@ -1,7 +1,6 @@
# Copyright 2108-2019 Sergio Teruel <sergio.teruel@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.addons.stock_barcodes.tests.test_stock_barcodes import\
TestStockBarcodes
from .test_stock_barcodes import TestStockBarcodes


class TestStockBarcodesInventory(TestStockBarcodes):
Expand Down Expand Up @@ -29,7 +28,7 @@ def test_inventory_values(self):
self.assertEqual(self.wiz_scan_inventory.res_id,
self.inventory.id)
self.assertEqual(self.wiz_scan_inventory.display_name,
'Barcode reader - Test Inventory - Administrator')
'Barcode reader - Test Inventory - OdooBot')

def test_inventory_wizard_scan_product(self):
self.action_barcode_scanned(self.wiz_scan_inventory, '8480000723208')
Expand Down
6 changes: 3 additions & 3 deletions stock_barcodes/tests/test_stock_barcodes_picking.py
Expand Up @@ -17,8 +17,8 @@ def setUp(self):
self.supplier_location = self.env.ref('stock.stock_location_suppliers')
self.customer_location = self.env.ref('stock.stock_location_customers')
self.stock_location = self.env.ref('stock.stock_location_stock')
self.categ_unit = self.env.ref('product.product_uom_categ_unit')
self.categ_kgm = self.env.ref('product.product_uom_categ_kgm')
self.categ_unit = self.env.ref('uom.product_uom_categ_unit')
self.categ_kgm = self.env.ref('uom.product_uom_categ_kgm')
self.picking_out_01 = self.env['stock.picking'].with_context(
planned_picking=True
).create({
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_wiz_picking_values(self):
self.assertEqual(self.wiz_scan_picking.res_id,
self.picking_in_01.id)
self.assertEqual(self.wiz_scan_picking.display_name,
'Barcode reader - %s - Administrator' % (
'Barcode reader - %s - OdooBot' % (
self.picking_in_01.name))

def test_picking_wizard_scan_product(self):
Expand Down
2 changes: 1 addition & 1 deletion stock_barcodes/views/assets.xml
Expand Up @@ -6,7 +6,7 @@
<script type="application/javascript"
src="/stock_barcodes/static/src/js/stock_barcodes.js"/>
<script type="application/javascript"
src="/stock_barcodes/static/src/js/basic_field.js"/>
src="/stock_barcodes/static/src/js/basic_fields.js"/>
<link rel="stylesheet" href="/stock_barcodes/static/src/css/stock.css"/>
</xpath>
</template>
Expand Down
10 changes: 6 additions & 4 deletions stock_barcodes/views/stock_picking_views.xml
Expand Up @@ -25,10 +25,12 @@
<field name="inherit_id" ref="stock.stock_picking_type_kanban"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('o_kanban_card_content')]" position="after">
<div class="row text-center" t-if="['incoming', 'outgoing', 'internal'].indexOf(record.code.raw_value) > -1">
<button name="action_barcode_scan" type="object" class="btn btn-info">
<i class="fa fa-barcode fa-2x"/>
</button>
<div class="container o_kanban_card_content o_visible">
<div class="text-center" t-if="['incoming', 'outgoing', 'internal'].indexOf(record.code.raw_value) > -1">
<button name="action_barcode_scan" type="object" class="btn btn-info">
<i class="fa fa-barcode fa-2x"/>
</button>
</div>
</div>
</xpath>
</field>
Expand Down
13 changes: 4 additions & 9 deletions stock_barcodes/wizard/stock_barcodes_read.py
Expand Up @@ -19,30 +19,25 @@ class WizStockBarcodesRead(models.AbstractModel):
res_id = fields.Integer(index=True)
product_id = fields.Many2one(
comodel_name='product.product',
string='Product',
)
product_tracking = fields.Selection(
related='product_id.tracking',
readonly=True,
)
lot_id = fields.Many2one(
comodel_name='stock.production.lot',
string='Lot',
)
location_id = fields.Many2one(
comodel_name='stock.location',
string='Location',
)
packaging_id = fields.Many2one(
comodel_name='product.packaging',
string='Packaging',
)
packaging_qty = fields.Float(
string='Package Qty',
digits=dp.get_precision('Product Unit of Measure'),
)
product_qty = fields.Float(
string='Product Qty',
digits=dp.get_precision('Product Unit of Measure'),
)
manual_entry = fields.Boolean(
Expand Down Expand Up @@ -72,16 +67,16 @@ def onchange_packaging_qty(self):
if self.packaging_id:
self.product_qty = self.packaging_qty * self.packaging_id.qty

def _set_messagge_info(self, type, messagge):
def _set_messagge_info(self, message_type, message):
"""
Set message type and message description.
For manual entry mode barcode is not set so is not displayed
"""
self.message_type = type
self.message_type = message_type
if self.barcode:
self.message = _('Barcode: %s (%s)') % (self.barcode, messagge)
self.message = _('Barcode: %s (%s)') % (self.barcode, message)
else:
self.message = '%s' % messagge
self.message = '%s' % message

def process_barcode(self, barcode):
self._set_messagge_info('success', _('Barcode read correctly'))
Expand Down
1 change: 0 additions & 1 deletion stock_barcodes/wizard/stock_barcodes_read_inventory.py
Expand Up @@ -13,7 +13,6 @@ class WizStockBarcodesReadInventory(models.TransientModel):

inventory_id = fields.Many2one(
comodel_name='stock.inventory',
string='Inventory',
readonly=True,
)
inventory_product_qty = fields.Float(
Expand Down
Expand Up @@ -19,7 +19,7 @@
Open wizard in current target option to avoid that the wizard is
closed after any button click,
-->
<record model="ir.actions.act_window" id="action_stock_barcodes_read_inventory">
<record id="action_stock_barcodes_read_inventory" model="ir.actions.act_window">
<field name="res_model">wiz.stock.barcodes.read.inventory</field>
<field name="name">Barcodes Read</field>
<field name="view_type">form</field>
Expand Down
4 changes: 2 additions & 2 deletions stock_barcodes/wizard/stock_barcodes_read_picking.py
Expand Up @@ -266,13 +266,13 @@ class WizCandidatePicking(models.TransientModel):
wiz_picking_id = fields.Many2one(
comodel_name='stock.picking',
related='wiz_barcode_id.picking_id',
string='Picking',
string='Wizard Picking',
readonly=True,
)
name = fields.Char(
related='picking_id.name',
readonly=True,
string='Picking',
string='Candidate Picking',
)
partner_id = fields.Many2one(
comodel_name='res.partner',
Expand Down
Expand Up @@ -79,7 +79,7 @@
<label for="confirmed_moves">
Confirmed moves allowed
</label>
<field name="confirmed_moves" widget="boolean_toggle"/>
<field name="confirmed_moves" widget="barcode_boolean_toggle"/>
</xpath>
<field name="location_id" position="before">
<field name="picking_type_code" invisible="1" force_save="1"/>
Expand Down

0 comments on commit c567261

Please sign in to comment.