콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

Hello everyone,


To explain the context, I created a custom module with a model that inherits from stock.scrap. This model automatically creates a barcode for scrap when it is created. Here's the code:

from odoo import models, fields, api

class StockScrapInherit(models.Model):
_inherit = ['stock.scrap']
barcode = fields.Char(string='Code-barres')

@api.model
def create(self, vals):
# Get the last barcode. If null, create the default one
last_scrap = self.env['stock.scrap'].search([], order='barcode desc', limit=1)
last_barcode = last_scrap.barcode if last_scrap else 'SCRAP-A0000'

if not isinstance(last_barcode, str):
last_barcode = 'SCRAP-A0000'

last_letter = last_barcode[6]
last_number = int(last_barcode[7:])

if last_number new_number = last_number + 1
new_barcode = 'SCRAP-' + last_letter + str(new_number).zfill(4)
else:
new_letter = chr(ord(last_letter) + 1)
new_barcode = 'SCRAP-' + new_letter + '0001'

vals['barcode'] = new_barcode

record = super(StockScrapInherit, self).create(vals)
return record

However, I can't manage to inherit the Barcode module that would allow me to redirect to the scrap page when its barcode is scanned. 


Do you have any idea how to do this?


Thanks in advance!

아바타
취소
관련 게시물 답글 화면 활동
0
3월 24
1702
0
11월 23
1770
2
9월 23
4077
0
4월 18
3661
2
3월 15
6097