I want click button create sale order data product in form custom transfer to form sale order.
file.py:
class custommodel(models.Model):
_name = 'custom.test'
_inherit = ['sale.order']
def create_sale_order(self):
return {
'name': 'Create Sale Order',
'res_model': 'sale.order',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'views': [(self.env.ref('sale.view_order_form').id, 'form')],
'view_id': self.env.ref('sale.view_order_form').id,
'target': 'current', }
class citem(models.Model):
_name = 'item'
product = fields.Many2one('product.product', string='Product Name')
c_id = fields.Many2one(' custom.test')
file.xml:
<button name="create_sale_order" string="Sale Order" type="object" class="oe_highlight"
context="{'default_product_id': product}"/>
Error: name 'product' is not defined
What to do to make the product field known in class custom.test , transfer to sale.order.line؟
Hi, sorry to say, Your code is messed up a lot.
Check the "create invoice button" in sale order to have a better understanding about creating a new record and open its view.