I have inherited res.partner and added this the field vendor_code.
the field's been added and I have filled the vendor_code with some values.
classPoPartner(models.Model):
_inherit= ['res.partner']
vendor_code= fields.Char('Supplier Short Code')
I'm trying to generate a sequence where it will use the value of the selected field.
but every time it gives company_code as 'None'
here is what it generates: LP/None/2023/7/0000036
classPurhcasePo(models.Model):
_name="purchase.po"
_description="Purchase PO" #po custom ref generator
@api.model
defcreate(self, vals):
serial_no=self.env['ir.sequence'].get('purchase.po.customized.sequence')
company_code=str(vals.get(self.env['res.partner'].browse(vals['partner_id']).vendor_code))
order_type=vals.get('order_type', False)
current_year=str(datetime.datetime.now().year)
current_month=str(datetime.datetime.now().month)
# merge prefix and serial number
vals['custom_po_ref'] =order_type+'/'+company_code+'/'+current_year+'/'+current_month+'/'+serial_no
returnsuper(PurhcasePo, self).create(vals)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1
Trả lời
2365
Lượt xem
Hi,
Modify this line of code and see:
company_code=str(vals.get(self.env['res.partner'].browse(vals['partner_id']).vendor_code))
To
company_code=str(self.env['res.partner'].browse(vals['partner_id']).vendor_code)
Thanks
Thank you
It worked
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 9 17
|
2995 | ||
|
1
thg 7 24
|
3266 | ||
|
3
thg 10 20
|
6442 | ||
|
1
thg 11 23
|
9862 | ||
|
2
thg 2 25
|
6031 |