12 changed files with 222 additions and 40 deletions
@ -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") |
@ -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 |
|||
|
@ -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 |
|||
|
@ -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") |
|||
|
|||
|
@ -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> |
@ -1,15 +1,14 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<odoo> |
|||
<data> |
|||
<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> |
|||
<field name="inherit_id" ref="purchase.purchase_order_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="before"> |
|||
<field name ="barcode_scan"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</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> |
|||
<field name="inherit_id" ref="purchase.purchase_order_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="before"> |
|||
<field name ="barcode_scan"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
@ -1,15 +1,14 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<odoo> |
|||
<data> |
|||
<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> |
|||
<field name="inherit_id" ref="sale.view_order_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="before"> |
|||
<field name ="barcode_scan"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</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> |
|||
<field name="inherit_id" ref="sale.view_order_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="before"> |
|||
<field name ="barcode_scan"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
|||
|
@ -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…
Reference in new issue