|
|
@ -33,15 +33,25 @@ class opendons_payment_batch(models.Model): |
|
|
|
# ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
partner_id=fields.Many2one( |
|
|
|
'res.partner', |
|
|
|
string='Partner', |
|
|
|
index=True, |
|
|
|
track_visibility='onchange', |
|
|
|
ondelete='restrict' |
|
|
|
) |
|
|
|
|
|
|
|
operation_id=fields.Many2one( |
|
|
|
'opendons.operation', |
|
|
|
string='Operation', |
|
|
|
|
|
|
|
index=True, |
|
|
|
domain=[('state', '=', 'exported')], |
|
|
|
track_visibility='onchange', |
|
|
|
ondelete='restrict' |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
segment_id=fields.Many2one( |
|
|
|
'opendons.segment', |
|
|
|
string='Segment', |
|
|
@ -71,9 +81,51 @@ class opendons_payment_batch(models.Model): |
|
|
|
res = {} |
|
|
|
res['domain']={'segment_id':[('operation_id', '=', self.operation_id.id)]} |
|
|
|
return res |
|
|
|
|
|
|
|
|
|
|
|
@api.onchange("payment_input") |
|
|
|
def _onchange_payment_input(self): |
|
|
|
|
|
|
|
if self.payment_input: |
|
|
|
|
|
|
|
|
|
|
|
inpt=self.payment_input.split(';') |
|
|
|
if len(inpt)!=4:raise ValidationError('input string not valid') |
|
|
|
partner_id=int(inpt[0]) |
|
|
|
key=inpt[1] |
|
|
|
operation_id=int(inpt[2]) |
|
|
|
segment_id=int(inpt[3]) |
|
|
|
|
|
|
|
partner = self.env['res.partner'].sudo().search(['&',('id','=',int(partner_id)),('key','=',key)]) |
|
|
|
operation = self.env['res.partner'].sudo().search([('id','=',int(operation_id))]) |
|
|
|
segment = self.env['res.partner'].sudo().search([('id','=',int(segment_id))]) |
|
|
|
|
|
|
|
if not partner : ValidationError('partner not found') |
|
|
|
if not operation : ValidationError('operation not found') |
|
|
|
if not segment : ValidationError('segment not found') |
|
|
|
|
|
|
|
|
|
|
|
self.partner_id=partner_id |
|
|
|
self.operation_id=operation_id |
|
|
|
self.segment_id=segment_id |
|
|
|
res=self.action_ajouter_payment() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def action_ajouter_payment(self): |
|
|
|
|
|
|
|
vals={} |
|
|
|
vals['payment_batch_id']=self.id |
|
|
|
vals['partner_id']=self.partner_id.id |
|
|
|
vals['operation_id']=self.operation_id.id |
|
|
|
vals['segment_id']=self.segment_id.id |
|
|
|
vals['donation_date']=fields.Date.context_today(self) |
|
|
|
self.env['donation.donation'].create(vals) |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
class opendons_payment_batch_lines(models.Model): |
|
|
|