Skip to content

Commit

Permalink
[FIX]sale_barcode: order line creation on scan
Browse files Browse the repository at this point in the history
X-original-commit: a342dbd
  • Loading branch information
JrAdhoc committed Feb 6, 2023
1 parent f6bc058 commit e323bde
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sale_barcode/__manifest__.py
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Sale Barcode',
'version': "15.0.1.0.0",
'version': "15.0.1.1.0",
'category': 'Sales',
'sequence': 14,
'summary': '',
Expand Down
6 changes: 4 additions & 2 deletions sale_barcode/models/sale_order.py
Expand Up @@ -5,14 +5,16 @@
from odoo import models, _



class SaleOrder(models.Model):

_name = 'sale.order'
_inherit = ['sale.order', 'barcodes.barcode_events_mixin']



def on_barcode_scanned(self, barcode):
product = self.env[
'product.product'].search([('barcode', '=', barcode)])
product = self.env['product.product'].search(['|', ('barcode', '=', barcode), ('default_code', '=', barcode)], limit=1)
if product:
self._add_product(product)
else:
Expand Down
9 changes: 3 additions & 6 deletions sale_barcode/static/src/js/sale_barcode_handler.js
@@ -1,17 +1,13 @@
odoo.define('sale_barcode.SaleBarcodeHandler', function (require) {
"use strict";

var core = require('web.core');
var AbstractField = require('web.AbstractField');
var field_registry = require('web.field_registry');

var _t = core._t;
var fieldRegistry = require('web.field_registry');


var SaleBarcodeHandler = AbstractField.extend({
init: function() {
this._super.apply(this, arguments);

this.trigger_up('activeBarcode', {
name: this.name,
fieldName: 'order_line',
Expand All @@ -25,7 +21,8 @@ var SaleBarcodeHandler = AbstractField.extend({
},
});

field_registry.add('sale_barcode_handler', SaleBarcodeHandler);

fieldRegistry.add('sale_barcode_handler', SaleBarcodeHandler);

return SaleBarcodeHandler;

Expand Down
4 changes: 2 additions & 2 deletions sale_barcode/views/sale_order_view.xml
Expand Up @@ -7,10 +7,10 @@
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<form position="inside">
<field name="_barcode_scanned" widget="sale_barcode_handler" invisible="1"/>
<field name="_barcode_scanned" widget="sale_barcode_handler"/>
</form>
<xpath expr="//field[@name='order_line']/tree" position="inside">
<field name="product_barcode" invisible="1"/>
<field name="product_barcode"/>
</xpath>
<xpath expr="//field[@name='order_line']//field[@name='product_uom_qty']" position="attributes">
<attribute name="options">{'barcode_events': True}</attribute>
Expand Down

0 comments on commit e323bde

Please sign in to comment.