0

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

Automated Action Settings image

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?

Javad
  • 2,033
  • 3
  • 13
  • 23
  • What is your question? – ewokx Aug 05 '22 at 01:27
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 05 '22 at 01:27

0 Answers0