Browse Source

lot de paiement affectation simpl : generation don

master
root 3 years ago
parent
commit
b96f7c0ef5
5 changed files with 65 additions and 27 deletions
  1. +2
    -1
      models/__init__.py
  2. +45
    -22
      models/payment_batch.py
  3. +1
    -1
      security/ir.model.access.csv
  4. +2
    -1
      views/payment_batch.xml
  5. +15
    -2
      views/templates.xml

+ 2
- 1
models/__init__.py View File

@ -11,4 +11,5 @@ from . import mailing_mailing
from . import relationship
from . import returnmail
from . import payment_batch
from . import sale_order
from . import sale_order
from . import product

+ 45
- 22
models/payment_batch.py View File

@ -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'
# )

+ 1
- 1
security/ir.model.access.csv View File

@ -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

+ 2
- 1
views/payment_batch.xml View File

@ -40,9 +40,10 @@
<field name="create_date"/>
<field name="create_uid"/>
<field name="payment_mode_id"/>
<field name="payment_mode_id"/>
<field name="input_mode"/>
<field name="assignment"/>
<field name="donation_amount" attrs="{'invisible':[('assignment','not in','single')]}"/>
<field name="product_id" attrs="{'invisible':[('assignment','not in','single')]}"/>
<br></br>
<br></br>
<field name="payment_input"/>


+ 15
- 2
views/templates.xml View File

@ -2,15 +2,28 @@
<odoo>
<template id="opendons_products_item" inherit_id="website_sale.products_item">
<xpath expr="//t[@t-set='combination_info']" position="after">
<t t-set="special_price" t-value="product._get_special_price(only_template=True, add_qty=add_qty or 1, pricelist=pricelist)"/>
</xpath>
<xpath expr="//div[@class='product_price']" position="replace">
<div t-if="not product.donation">
<del t-attf-class="text-danger mr-2 {{'' if combination_info['has_discounted_price'] else 'd-none'}}" style="white-space: nowrap;" t-esc="combination_info['list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
<span t-if="combination_info['price']" t-esc="combination_info['price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
Non Adhérent: <span t-if="combination_info['price']" t-esc="combination_info['price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
<br></br>
Adhérent: <span t-if="special_price['price_adherent']" t-esc="special_price['price_adherent']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
<br></br>
Soutien et Sangha: <span t-if="special_price['price_soutien']" t-esc="special_price['price_soutien']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
<span itemprop="price" style="display:none;" t-esc="combination_info['price']" />
<span itemprop="priceCurrency" style="display:none;" t-esc="website.currency_id.name" />
<span itemprop="priceCurrency" style="display:none;" t-esc="website.currency_id.name" />
</div>
</xpath>
</template>
</odoo>

Loading…
Cancel
Save