Browse Source

Jan 18 [FIX] : Bug Fixed

pull/232/head
AjmalCybro 2 years ago
parent
commit
26dcf86267
  1. 2
      serial_no_from_mo/__manifest__.py
  2. 30
      serial_no_from_mo/models/product_template.py

2
serial_no_from_mo/__manifest__.py

@ -21,7 +21,7 @@
#############################################################################
{
'name': 'Generate Lot/Serial Number From Manufacturing Order',
'version': '15.0.1.0.0',
'version': '15.0.1.0.1',
'summary': """Auto generate Serial/lot from manufacturing order""",
'description': """Automatically generates lot/serial number for product while confirming
the manufacturing order.User can set lot/seral number sequence in

30
serial_no_from_mo/models/product_template.py

@ -20,7 +20,7 @@
#
#############################################################################
from odoo import models, fields, api
from odoo import models, fields
class ProductTemplate(models.Model):
@ -36,11 +36,13 @@ class MrpProduction(models.Model):
def action_confirm(self):
parms = self.env['ir.config_parameter'].sudo()
type = parms.get_param('serial_selection')
if self.product_id.tracking == 'serial' or self.product_id.tracking == 'lot':
for rec in self:
if rec.product_id.tracking == 'serial' or rec.product_id.tracking == 'lot':
if type == 'global':
digit = parms.get_param('digit')
prefix = parms.get_param('prefix')
seq = self.env['ir.sequence'].sudo().search([('code', '=', 'mrp.production.sequence')])
if seq:
seq.write({
'prefix': prefix,
@ -55,27 +57,27 @@ class MrpProduction(models.Model):
'padding': digit})
serial_id = self.env['stock.production.lot'].create({
'name': self.env['ir.sequence'].sudo().next_by_code('mrp.production.sequence'),
'product_id': self.product_id.id,
'company_id': self.company_id.id,
'product_id': rec.product_id.id,
'company_id': rec.company_id.id,
})
else:
seq = self.env['ir.sequence'].sudo().search([('code', '=', self.product_id.name)])
seq = self.env['ir.sequence'].sudo().search([('code', '=', rec.product_id.name)])
if seq:
seq.write({
'prefix': self.product_id.product_tmpl_id.prefix,
'padding': self.product_id.product_tmpl_id.digit,
'prefix': rec.product_id.product_tmpl_id.prefix,
'padding': rec.product_id.product_tmpl_id.digit,
})
if not seq:
self.env['ir.sequence'].create({
'name': 'Mrp Production',
'implementation': 'standard',
'code': self.product_id.name,
'prefix': self.product_id.product_tmpl_id.prefix,
'padding': self.product_id.product_tmpl_id.digit})
'code': rec.product_id.name,
'prefix': rec.product_id.product_tmpl_id.prefix,
'padding': rec.product_id.product_tmpl_id.digit})
serial_id = self.env['stock.production.lot'].create({
'name': self.env['ir.sequence'].sudo().next_by_code(self.product_id.name),
'product_id': self.product_id.id,
'company_id': self.company_id.id,
'name': self.env['ir.sequence'].sudo().next_by_code(rec.product_id.name),
'product_id': rec.product_id.id,
'company_id': rec.company_id.id,
})
self.lot_producing_id = serial_id
rec.lot_producing_id = serial_id
return super(MrpProduction, self).action_confirm()

Loading…
Cancel
Save