Skip to Content
Menu
This question has been flagged
1 Reply
2640 Views

Facing this error on clicking the (Consumption Form) Button

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/odoo15/odoo/odoo/http.py", line 643, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo15/odoo/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
KeyError: 'ir.action.act_window'



consumption button.py

from odoo import models, fields, api


class ConsumptionButton(models.Model):
_inherit = "sale.order"

def consumption_form_function(self):
# view = self.env.ref('ct_marquee_management.consumption_form_action')
return {
'res_model': 'popup.form',
'res_id': self.partner_id.ids,
'type': 'ir.action.act_window',
'view_mode': 'form',
'view_id': [[self.env.ref('ct_marquee_management.popup_type_action').id, 'form']],
'target': 'new',
}
consumption button view.xml

xml version="1.0" encoding="UTF-8" ?>

id="sale_order_inherited_view" model="ir.ui.view">
name="name">sale.order.inherit
name="model">sale.order
name="inherit_id" ref="sale.view_order_form"/>
name="arch" type="xml">
expr="//header" position="inside">



consumption form.py

from odoo import models, fields, api


class ProductConsumption(models.Model):
_name = 'product.consumption'
name = fields.Char('Name')
order_id = fields.Many2one('sale.order', string='Sale Order')
product_consumption_line_ids = fields.One2many('product.consumption.line', 'product_consumption_id',
string='Sale Order')


class ProductConsumptionLine(models.Model):
_name = 'product.consumption.line'

department_id = fields.Many2one('hr.department', string='Department Name')
product_id = fields.Many2one('product.product', string='Product Name')
uom_id = fields.Many2one('uom.uom', string='Unit of Measure')
quantity = fields.Float(string='Quantity')
product_consumption_id = fields.Many2one('product.consumption')

consumption form view.xml

xml version="1.0" encoding="utf-8" ?>

id='consumption_form_action' model='ir.actions.act_window'>
name="name">Consumption Form
name="res_model">product.consumption
name="view_mode">tree,form
name="type">ir.actions.act_window


name="Consumption Form"
id="consumption_form"
parent="sale.product_menu_catalog"
action="consumption_form_action"/>

id="consumption_form_view_form" model="ir.ui.view">
name="name">Consumption Form
name="model">product.consumption
name="arch" type="xml">



name="name"/>
name="order_id"/>


string="Consumption Line">
name="product_consumption_line_ids">
editable="bottom">
name="department_id"/>
name="product_id"/>
name="uom_id"/>
name="quantity"/>















Avatar
Discard
Best Answer

Hello Yasir,

Please change "type": "ir.actions.act_window" instead of "ir.action.act_window". It is just small spelling mistake.

I hope this will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard
Related Posts Replies Views Activity
1
Mar 23
944
3
Aug 24
3489
2
Jun 22
3873
2
Dec 24
3122
1
Dec 24
350