Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3687 Lượt xem

Hi everyone,


I'm beginner on Odoo12 and I'm trying to update a data in the database using custom module, but it's not working.

Thanks for your help.


class IrSequence(models.Model):
_inherit = "ir.sequence"

@api.model
def _update_sequence(self):
cr = self._cr
cr.execute("SELECT id FROM ir_sequence WHERE name = 'BILL Sequence' LIMIT 1")
sequence_data = cr.fetchone()

if sequence_data:
cr.execute(
"UPDATE ir_sequence SET name='INV Sequence', implementation='standard', prefix='INV/%(range_year)s/', use_data_range=0 WHERE id = %s",
(sequence_data[0]))
return True
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

It looks like you're trying to update the sequence numbering. You can do that through a configuration settings rather than writing a custom module.

It's under the Settings -> Technical -> Sequences & Identifiers -> Sequences menu. Typing in Sequences on the search bar on the home page should bring it up.

Also note that it is usually easier, and safer, to update data through the API instead of directly through the SQL database. 

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thank for your answer. So It's more difficult and dangerous to do it through a custom.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 6 22
5440
1
thg 3 19
5937
3
thg 9 17
22739
2
thg 9 21
3785
5
thg 12 19
5376