Right now I am working on an automated action for Sales Orders to automatically create subscriptions. The action triggers if there are products, which includes a bill of material, which includes a subscription product to create an entry in the Subscription Module. As of now Odoo automatically creates a subscription entry if the sales order has a subscription product itself and not being part of a bundle.
Automated Action Settings
sub = record.env['sale.subscription']
vals = {
'company_id': 3,
'partner_id': self.partner_id.id,
'pricelist_id': self.pricelist_id.id,
'template_id': self.order_line.product_id.bom_ids.bom_line_ids.product_id.subscription_template_id.id,
'code': self.name,
'name': 'Name'
}
self.env.cr.commit()
With the code above I only get errors and couldn't create a subscription and do not know why? The error messages are not helpful and not related to the code.
Error:
RPC_ERROR: Odoo Server Error
at makeErrorFromResponse (https://odoo-dev.secusmart.de/web/assets/debug/web.assets_backend.js:6821:19) (/web/static/src/core/network/rpc_service.js:32)
at XMLHttpRequest.<anonymous> (https://odoo-dev.secusmart.de/web/assets/debug/web.assets_backend.js:6863:27) (/web/static/src/core/network/rpc_service.js:74)
How can I manage to create a subscription from an automated action?