diff --git a/__manifest__.py b/__manifest__.py index 7f377d9..d11394f 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -40,9 +40,12 @@ 'views/payment_batch.xml', 'views/website_sale.xml', 'views/aggregate.xml', - 'views/duplicate.xml', + 'views/duplicate.xml', + 'views/template_rf.xml', 'wizard/operation_duplicate_wizard.xml', - 'report/report_donationtax.xml' + 'report/report_donationtax.xml', + 'report/report.xml', + 'views/donation_tax_receipt.xml' #'views/website_donation.xml' diff --git a/models/__init__.py b/models/__init__.py index ef8a066..baaf148 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -14,3 +14,5 @@ from . import sale_order from . import product from . import aggregate from . import duplicate +from . import template_rf +from . import donation_tax_receipt diff --git a/models/donation_tax_receipt.py b/models/donation_tax_receipt.py new file mode 100644 index 0000000..f317912 --- /dev/null +++ b/models/donation_tax_receipt.py @@ -0,0 +1,26 @@ +from odoo import api, fields, models + + +class DonationTaxReceipt(models.Model): + _inherit = "donation.tax.receipt" + + template_rf_id=fields.Many2one('opendons.template_rf', 'RF template') + html_content=fields.Html('html content',compute='_html_content') + html_content_print=fields.Html('html content print') + + def action_print_rf(self): + self.ensure_one() + + + html_content_print=self.html_content + html_content_print=html_content_print.replace('{{partner_id.name}}',self.partner_id.name) + html_content_print=html_content_print.replace('{{partner_id.firstname}}',self.partner_id.firstname) + self.html_content_print=html_content_print + + #self.env['donation.tax_receipt'].write(vals) + #res=super(donation_tax_receipt, self).write(vals) + return self.env.ref("opendons.report_donation_tax_receipt").report_action(self) + #return True + + def _html_content(self): + self.html_content=self.template_rf_id.html_content \ No newline at end of file diff --git a/models/payment_batch.py b/models/payment_batch.py index 0ff8a9f..9d72bf0 100644 --- a/models/payment_batch.py +++ b/models/payment_batch.py @@ -25,7 +25,7 @@ class opendons_payment_batch(models.Model): product_id = fields.Many2one( 'product.product', 'Product', - required=True, + domain=[('donation', '=', True)], ondelete='restrict' diff --git a/models/template_rf.py b/models/template_rf.py new file mode 100644 index 0000000..c0f9e58 --- /dev/null +++ b/models/template_rf.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api +from odoo.exceptions import UserError, ValidationError +from psycopg2 import sql, DatabaseError +from odoo.tools.safe_eval import safe_eval, datetime + +from werkzeug import utils + + + +class opendons_template_rf(models.Model): + _name = 'opendons.template_rf' + _description = 'manage rf html template' + + name=fields.Char('name') + description=fields.Text('description') + active=fields.Boolean('active') + html_content=fields.Html('Html content') + + def action_update_receipts(self): + + rf=self.env['donation.tax.receipt'].search([('template_rf_id','=',int(self.id))]) + + for r in rf: + r.html_content=self.html_content \ No newline at end of file diff --git a/report/report.xml b/report/report.xml new file mode 100644 index 0000000..2e32825 --- /dev/null +++ b/report/report.xml @@ -0,0 +1,22 @@ + + + + + Donation Tax Receipt + donation.tax.receipt + qweb-pdf + opendons.report_donationtaxreceipt + opendons.report_donationtaxreceipt + 'Fiscal_receipt-'+(object.number or '').replace('/','')+'.pdf' + + + report + + \ No newline at end of file diff --git a/report/report_donationtax.xml b/report/report_donationtax.xml index 9e5518e..5bf15b5 100644 --- a/report/report_donationtax.xml +++ b/report/report_donationtax.xml @@ -2,7 +2,29 @@ -