readonly tax receipt
This commit is contained in:
parent
ee82b72199
commit
7362e4d7f1
@ -20,14 +20,6 @@ class DonationTaxReceipt(models.Model):
|
||||
compute="_compute_first_donation_date"
|
||||
)
|
||||
|
||||
def write(self, vals):
|
||||
raise UserError(_("Tax receipts cannot be modified manually. They must be generated from donations."))
|
||||
|
||||
@classmethod
|
||||
def create(cls, vals_list):
|
||||
raise UserError(_("Tax receipts cannot be created manually. They must be generated from donations."))
|
||||
|
||||
|
||||
@api.depends("donation_ids.donation_date")
|
||||
def _compute_first_donation_date(self):
|
||||
for receipt in self:
|
||||
|
||||
@ -471,7 +471,7 @@ msgstr "Partenaire"
|
||||
#: model_terms:ir.ui.view,arch_db:donation_base.donation_tax_receipt_form
|
||||
#, fuzzy
|
||||
msgid "Print"
|
||||
msgstr "Date d'impression"
|
||||
msgstr "Imprimer"
|
||||
|
||||
#. module: donation_base
|
||||
#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt__print_date
|
||||
|
||||
@ -54,6 +54,11 @@ class DonationTaxReceipt(models.Model):
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
def write(self, vals):
|
||||
if not self.env.context.get("allow_tax_receipt_write"):
|
||||
raise UserError(_("Tax receipts cannot be modified manually. They must be generated from donations."))
|
||||
super().write(vals)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
@ -99,3 +104,10 @@ class DonationTaxReceipt(models.Model):
|
||||
"context": ctx,
|
||||
}
|
||||
return action
|
||||
|
||||
def action_print_receipt(self):
|
||||
today = fields.Date.context_today(self)
|
||||
for receipt in self:
|
||||
if not receipt.print_date:
|
||||
receipt.with_context(allow_tax_receipt_write=True).write({"print_date": today})
|
||||
return self.env.ref("donation_base.report_donation_tax_receipt").report_action(self)
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
<field name="name">donation.tax.receipt.form</field>
|
||||
<field name="model">donation.tax.receipt</field>
|
||||
<field name="arch" type="xml">
|
||||
<form create="false" edit="0" delete="false">
|
||||
<form create="false" edit="false" delete="false">
|
||||
<header>
|
||||
<button
|
||||
name="action_send_tax_receipt"
|
||||
@ -19,9 +19,10 @@
|
||||
class="btn-primary"
|
||||
/>
|
||||
<button
|
||||
name="%(report_donation_tax_receipt)d"
|
||||
type="action"
|
||||
name="action_print_receipt"
|
||||
type="object"
|
||||
string="Print"
|
||||
class="btn-primary"
|
||||
/>
|
||||
</header>
|
||||
<sheet>
|
||||
|
||||
@ -27,8 +27,4 @@ class DonationTaxReceiptPrint(models.TransientModel):
|
||||
self.ensure_one()
|
||||
if not self.receipt_ids:
|
||||
raise UserError(_("There are no tax receipts to print."))
|
||||
today = fields.Date.context_today(self)
|
||||
self.receipt_ids.write({"print_date": today})
|
||||
return self.env.ref("donation_base.report_donation_tax_receipt").report_action(
|
||||
self.receipt_ids
|
||||
)
|
||||
return self.receipt_ids.action_print_receipt()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user