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

Hi,


I have to dynamically update a subscription according to some criteria in a contact record.
E.g. In a contact record, we store sales figures. If the last sales figues is less than an amount, I want to add a discount line in the customer's subscription. Next month, if the sales figues is more than an amount, I want to remove this line.

I think it should be possible with a scheduled action which will be executed 1 time / month. Each time, we check the contact sales figues and process the action to add / remove a subscription line. 

I just don't know the Python code to add / remove lines in a subscription through a scheduled action.


Thanks for assistance.


[Odoo 15 + Studio]

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

Hi Arnaud, 

Yes, it is possible to dynamically add/remove product lines in a subscription in Odoo 15 using a scheduled action. Here's an example code snippet to get you started:

pythonCopy codefrom odoo import api, models

class UpdateSubscription(models.Model):
    _inherit = 'sale.subscription'

    @api.model
    def process_subscription_update(self):
        subscriptions = self.env['sale.subscription'

Regard,

Team Ksolves!

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi,

Thanks for your answer. We don't have custom module.
Is it possible to do that trough Odoo Scheduled Actions GUI?

https://neoone.fr/odoo_screenshot.jpg

Best regards

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
1214
Subscription scam Đã xử lý
1
thg 4 25
2737
2
thg 2 25
5241
2
thg 11 24
4677
1
thg 10 24
2400