I need to activate a checkbox that is in my sales model, but I would need it to be when the user presses a button when creating a credit note for the sales order that was made, I currently have the box made and it works "manual" way.
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ờ
Hello,
You need to use the search or browse method.
First of all you need to find the record id and after need to update.
For eg.
In Sales Order one boolean field and we need to mark active when invoice created.
In that case first of all we need to search the record.
I'm assuming that there is one field is Many2One and it's related to 'sale.order' and field name is sale_order_id.
def action_post(self):
res =super().action_post()
order_id = self.env['sale.order']search([('id', '=', self.sale_order_id.id)])
order_id.valid = true
return res
Thanks.
Suppose you have inherited a sale.order object and added a "Valid" field as below,
class SaleOrder(models.Model):
_inherit = 'sale.order'
valid = fields.Boolean("Valid")
Now you need to inherit the action_post() method (CONFIRM button) of the account.move object and add code to activate the checkbox of the sale order object.
class CreaditNote(models.Model):
_inherit = 'account.move'
def action_post(self):
res =super().action_post()
order_id = self.env['sale.order']search([('id', '=', 1)]) # Apply domain as per requirement.
order_id.valid = true
return res
In this case on click of confirm button on the credit note it will activate the checkbox on the sale order where id = 1
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 | |
---|---|---|---|---|
Add option to select field
Đã xử lý
|
|
3
thg 10 22
|
6101 | |
|
1
thg 4 22
|
18174 | ||
|
1
thg 5 25
|
888 | ||
|
2
thg 11 24
|
2101 | ||
|
4
thg 2 24
|
12244 |
thanks Pandya, I was checking it but I found a syntax error
order_id = self.env['sale.order']search([('id', '=', 1)])
^^^^^^
SyntaxError: invalid syntax - - -
What do you mean by domain application? how could i solve this?
Sorry, I'm a new in this.