Browse Source

lots de paiement : indicateurs

master
root 3 years ago
parent
commit
e36678c8d5
2 changed files with 41 additions and 2 deletions
  1. +25
    -1
      models/payment_batch.py
  2. +16
    -1
      views/payment_batch.xml

+ 25
- 1
models/payment_batch.py View File

@ -65,6 +65,8 @@ class opendons_payment_batch(models.Model):
'payment_batch_id', 'payment_batch_id',
string='donation', string='donation',
track_visibility='onchange') track_visibility='onchange')
@api.model @api.model
def _default_currency(self): def _default_currency(self):
@ -82,7 +84,7 @@ class opendons_payment_batch(models.Model):
default=_default_currency default=_default_currency
) )
payment_count=fields.Integer(string='payments count', readonly=True)
payment_count=fields.Integer(string='payments count', readonly=True,compute="_compute_total")
payment_input=fields.Char('Input field') payment_input=fields.Char('Input field')
input_mode=fields.Selection([('manual','manual'),('loyalty','loyalty QRCODE'),('prospect','prospect QRCODE')]) input_mode=fields.Selection([('manual','manual'),('loyalty','loyalty QRCODE'),('prospect','prospect QRCODE')])
assignment=fields.Selection([('single','single'),('multiple','multiple')]) assignment=fields.Selection([('single','single'),('multiple','multiple')])
@ -99,6 +101,13 @@ class opendons_payment_batch(models.Model):
default=lambda self: self.env.company default=lambda self: self.env.company
) )
amount_total = fields.Monetary(
'Total amount',
currency_field='currency_id',compute="_compute_total"
)
@api.onchange('operation_id') @api.onchange('operation_id')
def _onchange_operation_id(self): def _onchange_operation_id(self):
res = {} res = {}
@ -212,7 +221,22 @@ class opendons_payment_batch(models.Model):
return True return True
def _compute_total(self):
total=0
i=0
for donation_id in self.donation_ids:
for line in donation_id.line_ids:
line_total = line.quantity * line.unit_price
total += line_total
i=i+1
self.amount_total= total
self.payment_count= i
class opendons_payment_batch_qrcode(models.Model): class opendons_payment_batch_qrcode(models.Model):
_name = 'opendons.payment_batch_qrcode' _name = 'opendons.payment_batch_qrcode'
_description = 'store qrcode to avoid duplicate entries' _description = 'store qrcode to avoid duplicate entries'


+ 16
- 1
views/payment_batch.xml View File

@ -51,6 +51,8 @@
<field name="company_id" invisible="1"/> <field name="company_id" invisible="1"/>
</group> </group>
<notebook>
<page string="Donation Lines" name="lines">
<button name="action_add_payment" type="object" string="create donation" attrs="{'invisible':['|','|','|',('payment_mode_id','=',False),('input_mode','=',False),('assignment','=',False),('partner_id','=',False)]}" class="oe_highlight oe_edit_only"/> <button name="action_add_payment" type="object" string="create donation" attrs="{'invisible':['|','|','|',('payment_mode_id','=',False),('input_mode','=',False),('assignment','=',False),('partner_id','=',False)]}" class="oe_highlight oe_edit_only"/>
<field name="donation_ids"> <field name="donation_ids">
<tree create="0"> <tree create="0">
@ -62,7 +64,20 @@
</tree> </tree>
</field> </field>
<group name="total" class="oe_subtotal_footer oe_right">
<field
name="amount_total"
string="Total"
class="oe_subtotal_footer_separator"
/>
<field
name="payment_count"
string="Payments count"
class="oe_subtotal_footer_separator"
/>
</group>
</page>
</notebook>


Loading…
Cancel
Save