Skip to Content
Menu
This question has been flagged
1902 Views


good i need help please I explain my problem I have a discount class in which I have a field many2one to select the amount of the bonus and through a button with the access to the invoice class and I look for all the records that are in the credit status and I passed them to payment status but I need to feel it access the invoice table with the search method and then I need to take a tour, get the invoice numbers of each client separately now the remainder between bonus and the total of 1 bill per client or barias as long as the amount of the bonus is greater than the total of the invoice the method that I am using until the moment is this


this is the discount class where I make the method

class DiningRoomDiscount(models.Model):


 _name = 'dining.room.discount'

prueba = fields.Integer(string='Base imponible', )

 worker = fields.Many2one('hr.employee', 'Ficha del Trabajador:',compute='_get_vehicle')

 fact_id = fields.Many2one('dining.room', 'factura',)

 bond_id = fields.Many2one('dining.room.configuration.bond', 'bono',)

 ficha = fields.Char(string='ficha', compute='_get_vehicle')

 currency_id = fields.Many2one('res.currency', 'Currency',

  default=lambda self: self.env.user.company_id.currency_id.id, required=True)


 @api.multi

 def discount_method(self):

   for r in self:

    bond = r.bond_id.vat

    worker = r.worker.name

   result = self.env['dining.room'].search([('state','ilike','credit'),('amount_total', '<=', bond)])

     return result.write({

    'state': 'draft',

    'amount_total': - bond

    })


and this is the invoice class


class DiningRoom(models.Model):


 _name = 'dining.room'

 

 name = fields.Char(default=lambda self: _('New'), required=True, string='Nro. de Factura')

 amount_untaxed = fields.Monetary(string='Base imponible', readonly=True, track_visibility='always', compute='_amount_all', store=True)

 amount_total = fields.Monetary(string='Total', readonly=True, track_visibility='always', compute='_amount_all', store=True)

 reference = fields.Integer(string='Referencia Bancaria:',)

 worker = fields.Many2one('hr.employee', 'Ficha del Trabajador:')

 client = fields.Many2one('dining.room.client', 'Cedula del Cliente:')

 currency_id = fields.Many2one('res.currency', 'Currency',

  default=lambda self: self.env.user.company_id.currency_id.id, required=True)

 product_id = fields.Many2one('dining.products', related='product_ids.product_id', string='Comida')

 product_ids = fields.One2many('dining.room.order', 'order_id', string='Productos', required=True, copy=True, store=True)

 state = fields.Selection([

  ('credit', 'Credito'),

  ('transfer', 'Tranferencia'),

  ('cash', 'Efectivo'),

  # ('payment', 'Pago'),

  ], string=_('Status'), readonly=True, copy=False, index=True, default='credit', compute='_state')

 model_room = fields.Selection([

  ('credit','Credito'),

  ('transfer','Transferencia'),

  ('cash','Efectivo'),

 ],string="Pago", required=True, default='credit')

 date = fields.Datetime(string='Fecha', default=fields.Datetime.now)

 date2 = fields.Date(string='Fecha')

 option = fields.Selection([

  ('worker','trabajador'),

  ('client','cliente')

 ],string="opcion", required=True, default='worker')

Avatar
Discard