fix action_open_donation_catalog method

This commit is contained in:
MahmoudSalahEXP 2025-10-16 17:01:07 +03:00
parent 0a26ef6f09
commit 199d760fbc
1 changed files with 61 additions and 7 deletions

View File

@ -323,24 +323,78 @@ class TakafulSponsorship(models.Model):
def action_open_donation_catalog(self):
all_donation_lines = self.donations_details_lines | self.donations_details_lines_mechanism_ids
kanban_view = self.env.ref(
'odex_takaful.product_product_view_kanban')
return {
'type': 'ir.actions.act_window',
'name': _('Choose Donation Items'),
'res_model': 'product.template',
'views': [(False, 'kanban')],
'domain': [('id', 'not in', all_donation_lines.mapped('product_template_id').ids),('donation_category','=','donation')],
'target': 'new',
'views': [(kanban_view.id, 'kanban')],
'domain': [('id', 'not in', all_donation_lines.mapped('product_template_id').ids),
('donation_category', '=', 'donation'), ],
'context': {
# '_quantity_change': True,
'sponsorship_id': self.id,
'create': False
},
'help': _("""<p class="o_view_nocontent_smiling_face">
Create a new product
</p>""")
Create a new product
</p>""")
}
# return {
# 'type': 'ir.actions.act_window',
# 'name': _('Choose Donation Items'),
# 'res_model': 'product.template',
# 'views': [(False, 'kanban')],
# 'domain': [('id', 'not in', all_donation_lines.mapped('product_template_id').ids),('donation_category','=','donation')],
# 'target': 'new',
# 'context': {
# 'sponsorship_id': self.id,
# 'create': False
# },
#
# 'help': _("""<p class="o_view_nocontent_smiling_face">
# Create a new product
# </p>""")
# }
# def donation_catelog(self):
# cart_object = self.env["donations.details.lines"]
# donation_object = self.env["donations.items"]
# cart_products_details = cart_object.search(
# [('sponsorship_id', "=", self.id)]) # , ("cart_flag", "=", True)
# product_object_data = donation_object.search(
# [("_quantity", "!=", 0)])
# assign_quantity = 0
# for rec in product_object_data:
# rec._quantity = 0
# if len(cart_products_details) > 0:
# for rec in cart_products_details:
# if assign_quantity == 0:
# assign_quantity += 1
#
# kanban_view = self.env.ref(
# 'odex_takaful.product_product_view_kanban')
# all_donation_lines = self.donations_details_lines | self.donations_details_lines_mechanism_ids
#
# return {
# 'type': 'ir.actions.act_window',
# 'name': _('Choose Donation Items'),
# 'res_model': 'product.template',
# 'views': [(kanban_view.id, 'kanban')],
# 'domain': [('id', 'not in', all_donation_lines.mapped('product_template_id').ids),
# ('donation_category', '=', 'donation'), ],
# 'context': {
# # '_quantity_change': True,
# 'sponsorship_id': self.id,
# 'create': False
# },
# 'help': _("""<p class="o_view_nocontent_smiling_face">
# Create a new product
# </p>""")
# }
def action_replacement_processes(self):
return {
'name': _('Replacement Processes'),