diff --git a/models/__init__.py b/models/__init__.py index cfa5438..26873d7 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -11,4 +11,5 @@ from . import mailing_mailing from . import relationship from . import returnmail from . import payment_batch -from . import sale_order \ No newline at end of file +from . import sale_order +from . import product \ No newline at end of file diff --git a/models/payment_batch.py b/models/payment_batch.py index 28c43bd..1a4edc9 100644 --- a/models/payment_batch.py +++ b/models/payment_batch.py @@ -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' - # ) + \ No newline at end of file diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index 4a60ec0..36ff341 100644 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -20,4 +20,4 @@ access_opendons_returnmail,opendons_returnmail,model_opendons_returnmail,donatio access_opendons_returnmailnpai,opendons_returnmailnpai,model_opendons_returnmail_npai,donation.group_donation_manager,1,1,1,1 access_opendons_payment_batch,opendons_payment_batch,model_opendons_payment_batch,donation.group_donation_manager,1,1,1,1 -access_opendons_payment_batch_lines,opendons_payment_batch_lines,model_opendons_payment_batch_lines,donation.group_donation_manager,1,1,1,1 + diff --git a/views/payment_batch.xml b/views/payment_batch.xml index 2f0a257..6f3e55f 100644 --- a/views/payment_batch.xml +++ b/views/payment_batch.xml @@ -40,9 +40,10 @@ - + + diff --git a/views/templates.xml b/views/templates.xml index 2daaab2..687e524 100644 --- a/views/templates.xml +++ b/views/templates.xml @@ -2,15 +2,28 @@ + + + + - + Non Adhérent: + + Adhérent: + + Soutien et Sangha: + - + + + + + \ No newline at end of file