Browse Source

Oct 18 : [FIX] Bug Fixed 'barcode_scanning_sale_purchase'

pull/295/head
AjmalCybro 2 years ago
parent
commit
5718e364fe
  1. 1
      barcode_scanning_sale_purchase/__init__.py
  2. 6
      barcode_scanning_sale_purchase/__manifest__.py
  3. 5
      barcode_scanning_sale_purchase/doc/RELEASE_NOTES.md
  4. 5
      barcode_scanning_sale_purchase/models/__init__.py
  5. 30
      barcode_scanning_sale_purchase/models/account_move_line.py
  6. 53
      barcode_scanning_sale_purchase/models/purchase_order.py
  7. 54
      barcode_scanning_sale_purchase/models/sale_order.py
  8. 32
      barcode_scanning_sale_purchase/models/stock_move.py
  9. 14
      barcode_scanning_sale_purchase/views/account_move_views.xml
  10. 3
      barcode_scanning_sale_purchase/views/purchase_order_line.xml
  11. 3
      barcode_scanning_sale_purchase/views/sale_order_line.xml
  12. 14
      barcode_scanning_sale_purchase/views/stock_picking_views.xml

1
barcode_scanning_sale_purchase/__init__.py

@ -19,5 +19,4 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from . import models

6
barcode_scanning_sale_purchase/__manifest__.py

@ -21,17 +21,19 @@
{
'name': 'Barcode scanning support for sale and Purchase',
'version': '16.0.1.0.0',
'version': '16.0.2.1.0',
'category': 'Sales',
'live_test_url': 'https://www.youtube.com/watch?v=6tJZAfPu__s&feature=youtu.be',
'summary': 'This module will help you to use barcode scanner in sales and purchase.',
'author': 'Cybrosys Techno solutions',
'company': 'Cybrosys Techno Solutions',
'website': 'https://www.cybrosys.com',
'depends': ['purchase', 'sale_management'],
'depends': ['purchase', 'sale_management', 'stock'],
'data': [
'views/sale_order_line.xml',
'views/purchase_order_line.xml',
'views/stock_picking_views.xml',
'views/account_move_views.xml',
],
'installable': True,
'application': False,

5
barcode_scanning_sale_purchase/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 16.0.1.0.0
##### ADD
- Initial Commit
#### 16.10.2023
#### Version 16.0.2.1.0
##### ADD
- Inherited models and add fields, functions and add views for it

5
barcode_scanning_sale_purchase/models/__init__.py

@ -19,6 +19,7 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from . import sale_order
from . import account_move_line
from . import purchase_order
from . import sale_order
from . import stock_move

30
barcode_scanning_sale_purchase/models/account_move_line.py

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Sreejith P (<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import fields, models
class AccountMoveLine(models.Model):
"""Inherited the model for to add field for barcode."""
_inherit = 'account.move.line'
barcode_scan = fields.Char(string='Product Barcode',
help="Barcode for the product")

53
barcode_scanning_sale_purchase/models/purchase_order.py

@ -1,17 +1,62 @@
from odoo import api, models, fields
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Sreejith P (<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import api, fields, models
class PurchaseOrderLines(models.Model):
"""Inherited the model for add field for barcode."""
_inherit = "purchase.order.line"
barcode_scan = fields.Char(string='Product Barcode', help="Here you can provide the barcode for the product")
barcode_scan = fields.Char(string='Product Barcode',
help="Here you can provide the barcode for the "
"product")
@api.onchange('barcode_scan')
def _onchange_barcode_scan(self):
print('purchase')
"""Scanning the barcode will automatically add products to order line"""
product_rec = self.env['product.product']
if self.barcode_scan:
product = product_rec.search([('barcode', '=', self.barcode_scan)])
self.product_id = product.id
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
class PurchaseOrder(models.Model):
"""Added functions for pass the values from the order line to stock picking
and account move"""
_inherit = 'purchase.order'
def button_confirm(self):
"""Corresponding barcode of product will show in stock picking"""
res = super().button_confirm()
for rec in self.order_line:
self.env['stock.move'].search([('purchase_line_id', '=', rec.id)])[
'barcode_scan'] = rec.barcode_scan
return res
def action_create_invoice(self):
"""Corresponding barcode of product will show in account move line"""
res = super().action_create_invoice()
for rec in self.order_line:
self.env['account.move.line'].search(
[('purchase_line_id', '=', rec.id)])[
'barcode_scan'] = rec.barcode_scan
return res

54
barcode_scanning_sale_purchase/models/sale_order.py

@ -1,17 +1,59 @@
from odoo import api, models, fields
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Sreejith P (<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import api, fields, models
class SaleOrderLines(models.Model):
class SaleOrderLine(models.Model):
"""Inherited the model for to add field for barcode."""
_inherit = 'sale.order.line'
barcode_scan = fields.Char(string='Product Barcode', help="Here you can provide the barcode for the product")
barcode_scan = fields.Char(string='Product Barcode',
help="Here you can provide the barcode for "
"the product")
@api.onchange('barcode_scan')
@api.onchange('barcode_scan', 'product_template_id')
def _onchange_barcode_scan(self):
print('sale')
"""Scanning the barcode will automatically add products to order line"""
product_rec = self.env['product.product']
if self.barcode_scan:
product = product_rec.search([('barcode', '=', self.barcode_scan)])
self.product_id = product.id
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
def _prepare_invoice_line(self, **optional_values):
"""Corresponding barcode of product will show in account move"""
res = super(SaleOrderLine, self)._prepare_invoice_line(
**optional_values)
if self.barcode_scan:
res.update({'barcode_scan': self.barcode_scan})
return res
class SaleOrder(models.Model):
_inherit = 'sale.order'
def action_confirm(self):
"""Corresponding barcode of product will show in stock picking"""
res = super().action_confirm()
for rec in self.order_line:
self.env['stock.move'].search([('sale_line_id', '=', rec.id)])[
'barcode_scan'] = rec.barcode_scan
return res

32
barcode_scanning_sale_purchase/models/stock_move.py

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Sreejith P (<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import fields, models
class StockMove(models.Model):
"""Inherited the model for add field for barcode."""
_inherit = "stock.move"
barcode_scan = fields.Char(string='Product Barcode',
help="Barcode of the product")

14
barcode_scanning_sale_purchase/views/account_move_views.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- View for account move-->
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form.inherit.barcode.scanning.sale.purchase</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='product_id']" position="before">
<field name ="barcode_scan"/>
</xpath>
</field>
</record>
</odoo>

3
barcode_scanning_sale_purchase/views/purchase_order_line.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<!-- View for purchase order -->
<record id="purchase_order_view_inherit_barcode1" model="ir.ui.view">
<field name="name">purchase.order.form.inherit</field>
<field name="model">purchase.order</field>
@ -11,5 +11,4 @@
</xpath>
</field>
</record>
</data>
</odoo>

3
barcode_scanning_sale_purchase/views/sale_order_line.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<!-- View for sale order-->
<record id="sale_order_view_inherit_barcode1" model="ir.ui.view">
<field name="name">sale.order.form.inherit</field>
<field name="model">sale.order</field>
@ -11,5 +11,4 @@
</xpath>
</field>
</record>
</data>
</odoo>

14
barcode_scanning_sale_purchase/views/stock_picking_views.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- View for stock picking-->
<record id="view_picking_form" model="ir.ui.view">
<field name="name">stock.picking.view.form.inherit.barcode.scanning.sale.purchase</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='move_ids_without_package']/tree/field[@name='partner_id']" position="before">
<field name ="barcode_scan"/>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save