Open new page from model

  • Step 1:

    1. order model

    
                  class orders(models.Model):
                          _name='pickabite.orders'
                          _rec_name='order_id'
    
                      state = fields.Selection([
                                  ('draft','Draft'),
                                  ('confirmed', 'Confirmed'),
                                  ('bill','Bill'),
                                  ('in_payment', 'In Payment'),
                                  ('paid', 'Paid'),
                                  ('cancel', 'Cancelled'),],
                                  string='Status', index=True, readonly=True, default='draft',
                                  track_visibility='onchange', copy=False)
    
    
                                  #register payment button action
                                  @api.multi
                                  def in_payment(self):
                                      self.write({'state': 'in_payment'})
                                      return {
                                          #'name': self.order_id,
                                          'res_model': 'pickabite.payment',
                                          'type': 'ir.actions.act_window',
                                          'context': {},
                                          'view_mode': 'form',
                                          'view_type': 'form',
                                          'view_id': self.env.ref("pickabite.payment_form_view").id,
                                          'target': 'new'
                                      }
    
                      

    2. -payment model

    
                      class payment(models.Model):
                            _name='pickabite.payment'
                            _rec_name='bill_id'
                            bill_id=fields.Many2one('pickabite.orders',string='Bill Id')
                            customer_id=fields.Many2one(related='bill_id.customer_name',
                                    string='Customer Id')
                            bill_amount=fields.Float(related='bill_id.order_price',
                                    string='Bill amount')
    
                                    

    3. Order Form View

    
                   <record model="ir.ui.view" id="pickabite.order_form">
            <field name="name">Orders</field>
            <field name="model">pickabite.orders</field>
            <field name="arch" type="xml">
            <form string="Orders">
                <header>
                     
                    <button style=" background-color: lightblue;"
                        name="in_payment" string="Register Payment" states="bill"
                        type="action"/>
                     
                    <field name="state" widget="statusbar"
                        statusbar_visible="draft,confirmed,bill,in_payment,paid,
                                                cancel" />
                </header>
                <form>
                      <!--       -->
            </form>
          </field> 
        </record>
        
                                    

    4. Payment Form View

    
                                    <record model="ir.ui.view" id="pickabite.payment_form_view">
            <field name="name">Payment Form View</field>
            <field name="model">pickabite.payment</field>
            <field name="arch" type="xml">
            <form>
                     <!--  -->
            </form>
          </field> 
        </record>
    
                                    

    5. window action

    
    
                                    <record model="ir.actions.act_window" id="order_menu_action">
            <field name="name">Orders</field>
            <field name="res_model">pickabite.orders</field>
            <field name="view_type">form</field>
              <field name="view_mode">kanban,tree,form</field>
            <field name="domain">[]</field>
            <field name="help" type="html">
              <p class="o_view_nocontent_smiling_face">Create The First
                       Order</p>
            </field>
        </record>
    
                                    

    6. payment menu

    
    
                                    <record model="ir.actions.act_window" id="payment_menu_action">
            <field name="name">Payment</field>
            <field name="res_model">pickabite.payment</field>
            <field name="view_type">form</field>
              <field name="view_mode">form</field>
              <!--field name="view_id"/>
              <ref="pickabite.payment_form_view"/-->
              <field name="target">current</field>
        </record>