|
|
@ -22,15 +22,14 @@ class opendons_payment_batch(models.Model): |
|
|
|
tracking=True |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# product_id=fields.Many2one( |
|
|
|
# 'product.product', |
|
|
|
# string='Product', |
|
|
|
# index=True, |
|
|
|
# track_visibility='onchange', |
|
|
|
# ondelete='restrict' |
|
|
|
# ) |
|
|
|
product_id = fields.Many2one( |
|
|
|
'product.product', |
|
|
|
'Product', |
|
|
|
required=True, |
|
|
|
domain=[('donation', '=', True)], |
|
|
|
ondelete='restrict', |
|
|
|
store=False |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,11 +66,31 @@ class opendons_payment_batch(models.Model): |
|
|
|
string='donation', |
|
|
|
track_visibility='onchange') |
|
|
|
|
|
|
|
@api.model |
|
|
|
def _default_currency(self): |
|
|
|
company = self.env['res.company']._company_default_get( |
|
|
|
'donation.donation') |
|
|
|
return company.currency_id |
|
|
|
|
|
|
|
currency_id = fields.Many2one( |
|
|
|
'res.currency', |
|
|
|
string='Currency', |
|
|
|
required=True, |
|
|
|
states={'done': [('readonly', True)]}, |
|
|
|
track_visibility='onchange', |
|
|
|
ondelete='restrict', |
|
|
|
default=_default_currency |
|
|
|
) |
|
|
|
|
|
|
|
payment_count=fields.Integer(string='payments count', readonly=True) |
|
|
|
payment_input=fields.Char('Input field') |
|
|
|
input_mode=fields.Selection([('manual','manual'),('loyalty','loyalty QRCODE'),('prospect','prospect QRCODE')]) |
|
|
|
assignment=fields.Selection([('single','single'),('multiple','multiple')]) |
|
|
|
donation_amount = fields.Monetary( |
|
|
|
'Donation amount', |
|
|
|
currency_field='currency_id', |
|
|
|
store=False, |
|
|
|
) |
|
|
|
# payment_lines = fields.One2many( |
|
|
|
# 'opendons_payment_batch.lines', |
|
|
|
# 'payment_batch_id', |
|
|
@ -121,24 +140,28 @@ class opendons_payment_batch(models.Model): |
|
|
|
|
|
|
|
vals={} |
|
|
|
vals['payment_batch_id']=self.id |
|
|
|
vals['payment_mode_id']=int(self.payment_mode_id) |
|
|
|
vals['tax_receipt_option']='annual' |
|
|
|
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) |
|
|
|
donation=self.env['donation.donation'].create(vals) |
|
|
|
|
|
|
|
#creation de l'affectation du don si affectation simple |
|
|
|
if self.assignment=='single': |
|
|
|
vals={} |
|
|
|
vals['donation_id']=donation.id |
|
|
|
vals['currency_id']=self.currency_id |
|
|
|
#vals['company_currency_id']=self.company_currency_id |
|
|
|
vals['product_id']=int(self.product_id) |
|
|
|
vals['quantity']=1 |
|
|
|
vals['unit_price']=self.donation_amount |
|
|
|
donation_line=self.env['donation.line'].create(vals) |
|
|
|
|
|
|
|
donation.validate() |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
class opendons_payment_batch_lines(models.Model): |
|
|
|
_name = 'opendons_payment_batch.lines' |
|
|
|
_description = 'manage payment batch lines' |
|
|
|
_inherits = { |
|
|
|
'donation.donation': 'donation_id', |
|
|
|
} |
|
|
|
|
|
|
|
# payment_batch_id = fields.Many2one( |
|
|
|
# 'opendons_payment_batch', |
|
|
|
# string='Payment Batch', |
|
|
|
# ondelete='set null' |
|
|
|
# ) |
|
|
|
|
|
|
|
|