I want to automatically fill in the fields of the 'payment' model with the values from the fields 'customer_name', 'order_item' and 'order_price' in the 'orders' model.
Beginner. Please help
class payment(models.Model):
_name='pickabite.payment'
_rec_name='bill_id'
#generating bill_id
bill_id=fields.Char(string='Bill Id', readonly=True)
@api.model
def create(self, vals):
x = self.env['ir.sequence'].next_by_code('pickabite.payment') or '/'
vals['bill_id'] = x
return super(payment,self).create(vals)
class orders(models.Model):
_name='pickabite.orders'
_rec_name='order_id'
customer_name=fields.Many2one('pickabite.customer',
string='Customer Name',required=True)
#generating order_id
order_id = fields.Char(string='Order Id', Translate= True ,
readonly = True)
@api.model
def create(self, vals):
x = self.env['ir.sequence'].next_by_code('pickabite.orders') or '/'
vals['order_id'] = x
return super(orders, self).create(vals)
order_item=fields.One2many('pickabite.order_line','order_code',
string='Order Item', ondelete='cascade')
order_price=fields.Float(compute='calc_order_price' ,string='Total')
def calc_order_price(self):
..........