Merge branch 'dev_odex25_ensan' of https://github.com/expsa/odex25-standard-modules into replace_between_replace_wating

This commit is contained in:
odoo-syria-team 2025-11-19 16:03:31 +03:00
commit d1b30eff9d
10 changed files with 83 additions and 52 deletions

View File

@ -17347,11 +17347,6 @@ msgstr "يرجى اختيار سطر رجيع واحد على الأقل للح
msgid "Return Confirm"
msgstr "تأكيد الرجيع"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_benefit_expense_line__return_calculated
msgid "Return Already Calculated"
msgstr "تم حساب الرجيع بالفعل"
#. module: odex_benefit
#: model:ir.model.fields,help:odex_benefit.field_confirm_benefit_expense__is_return_calculation
msgid ""
@ -17361,4 +17356,10 @@ msgstr "تمكين لحساب المبالغ المرجعة بدلاً من ال
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
msgid "Return Lines"
msgstr "سطور الرجيع"
msgstr "سطور الرجيع"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_confirm_benefit_expense__line_domain_ids
msgid "Return Line Domain"
msgstr "مجال سطر الرجيع"

View File

@ -93,7 +93,10 @@ class ConfirmBenefitExpense(models.Model):
)
return_expense_line_ids = fields.One2many(comodel_name='benefit.expense.line', inverse_name='return_confirm_id',
string="Selected Return Lines",
domain="[('is_return', '=', True), ('return_calculated', '=', False)]", )
domain="[('is_return', '=', True)]", )
line_domain_ids = fields.Many2many(comodel_name='benefit.expense.line', compute='_compute_domain_ids',
string="Return Line Domain",
)
@api.depends('payment_order_id', 'payment_order_id.state', 'move_id', 'move_id.state')
def _compute_payment_move_state(self):
@ -176,7 +179,6 @@ class ConfirmBenefitExpense(models.Model):
'family_monthly_othaime': 0,
}))
self.benefit_expense_line_ids = lines
return_lines.write({'return_calculated': True})
def action_calculate(self):
for rec in self:
@ -221,18 +223,18 @@ class ConfirmBenefitExpense(models.Model):
validation_setting = self.env["family.validation.setting"].search([], limit=1)
if rec.is_return_calculation:
domain = [
('start_date', '<=', rec.end_date),
('end_date', '>=', rec.start_date),
('is_return', '=', True),
('return_reason_id', '!=', False),
('return_calculated', '=', False),
'|',
('return_confirm_id', '=', False),
('return_confirm_id', '=', rec.id),
('start_date', '>=', rec.start_date),
('end_date', '<=', rec.end_date),
]
if rec.branch_custom_ids:
domain.append(('branch_id', 'in', rec.branch_custom_ids.ids))
rec.family_domain_ids = Line.search(domain).mapped('family_id')
return_lines = Line.search(domain)
rec.line_domain_ids = return_lines
rec.family_domain_ids = return_lines.mapped('family_id')
else:
# Define base domain for family selection
@ -256,6 +258,7 @@ class ConfirmBenefitExpense(models.Model):
base_domain.append(('id', 'not in', conflicting_family_ids))
rec.family_domain_ids = self.env['grant.benefit'].search(base_domain)
rec.line_domain_ids = self.env['benefit.expense.line'].browse([])
@api.onchange('branch_custom_ids')
def _onchange_branch_custom_ids(self):
@ -312,7 +315,6 @@ class ConfirmBenefitExpense(models.Model):
self.payment_order_id.unlink()
self.move_id.unlink()
self.benefit_expense_line_ids.unlink()
self.return_expense_line_ids.write({'return_calculated': False})
self.state = 'draft'
def action_open_related_move_records(self):

View File

@ -28,7 +28,6 @@ class BenefitExpenseLine(models.Model):
payment_order_id = fields.Many2one('payment.orders', string='Payment Order', ondelete="set null", copy=False)
return_reason_id = fields.Many2one("return.reason", string="Return Reason")
is_return = fields.Boolean(string="Is Returned?", default=False)
return_calculated = fields.Boolean("Return Already Calculated", default=False, copy=False)
@api.depends('family_monthly_income', 'family_monthly_clotting', 'family_monthly_meals')
def _compute_total_family_expenses(self):

View File

@ -124,8 +124,7 @@ class ServiceRequest(models.Model):
payment_order_ids = fields.Many2many(comodel_name='payment.orders', relation='service_request_payment_order_rel',
column1='service_request_id',
column2='payment_order_id', string='Payment Orders', copy=False, )
payment_order_id = fields.Many2one('payment.orders', compute='_compute_payment_order', string='Payment Order',
copy=False, store=True)
payment_order_id = fields.Many2one('payment.orders', string='Payment Order', copy=False)
payment_order_count = fields.Integer(compute='_compute_payment_order', string='Number of Payment Orders')
is_payment_order_done = fields.Boolean(string='Is Payment Order Done?')
aid_amount = fields.Float(string='Aid Amount', compute='_get_aid_amount')
@ -232,10 +231,8 @@ class ServiceRequest(models.Model):
def _compute_payment_order(self):
for rec in self:
if rec.payment_order_ids:
rec.payment_order_id = rec.payment_order_ids.sorted('payment_order_date', reverse=True)[0]
rec.payment_order_count = len(rec.payment_order_ids)
else:
rec.payment_order_id = False
rec.payment_order_count = 0
@api.depends('payment_order_id', 'payment_order_id.state', 'vendor_bill', 'vendor_bill.state')
@ -246,7 +243,8 @@ class ServiceRequest(models.Model):
if rec.payment_order_id.state == "done":
payment_order_state = "done"
rec.service_approval_date = fields.Datetime.now()
rec.state = 'send_request_to_supplier'
if rec.state == 'accounting_approve':
rec.state = 'send_request_to_supplier'
rec.is_payment_order_done = True
else:
payment_order_state = "waiting"
@ -1035,9 +1033,11 @@ class ServiceRequest(models.Model):
) % cat_names)
if service_cats.payment_method == "payment_order":
# todo ask about this condition and seasonal services
invalid_records = self.filtered(
lambda r: r.state != 'accounting_approve')
lambda r: r.state != 'accounting_approve'
or r.payment_order_state != 'none'
or r.payment_order_id
)
if invalid_records:
names = ", ".join(invalid_records.mapped('name'))
@ -1057,6 +1057,7 @@ class ServiceRequest(models.Model):
})
self.write({
'payment_order_ids': [(4, payment_order.id)],
'payment_order_id': payment_order.id,
})
elif service_cats.payment_method == "invoice":

View File

@ -140,6 +140,7 @@
<field name="company_id" groups="base.group_multi_company"/>
<field name="currency_id" invisible="1" groups="base.group_multi_currency"/>
<field name="available_payment_method_line_ids" invisible="1"/>
<field name="line_domain_ids" invisible="1"/>
</group>
</group>
<!-- Notebook with Families page -->
@ -353,7 +354,7 @@
</field>
</page>
<page string="Return Lines" attrs="{'invisible': [('is_return_calculation', '=', False)]}">
<field name="return_expense_line_ids" widget="many2many" domain="[('family_id', 'in', family_domain_ids)]"
<field name="return_expense_line_ids" widget="many2many" domain="[('id', 'in', line_domain_ids)]"
attrs="{'readonly':[('state', '!=', 'draft')]}">
<tree>
<field name="family_id"/>

View File

@ -102,7 +102,7 @@
type="object"
string="Bank Return"
class="btn btn-danger"
attrs="{'invisible': ['|',('return_reason_id', '!=', False),('parent.state', '!=', 'done')]}"
attrs="{'invisible': ['|',('state', '!=', 'accounting_approve'),('parent.state', '!=', 'waiting_deposit')]}"
/>
</tree>
</field>
@ -143,7 +143,7 @@
type="object"
string="Bank Return"
class="btn btn-danger"
attrs="{'invisible': ['|',('is_return', '=', True),('parent.state', '!=', 'done')]}"
attrs="{'invisible': ['|',('is_return', '=', True),('parent.state', '!=', 'waiting_deposit')]}"
/>
</tree>
</field>

View File

@ -32,5 +32,6 @@ class ReturnReasonWizard(models.TransientModel):
record.is_return = True
if self.line_model == "service.request" and hasattr(record, "state"):
record.state = "return_to_bank"
record.payment_order_id = False
return {'type': 'ir.actions.act_window_close'}

View File

@ -2239,7 +2239,7 @@ msgstr "تمديد"
#: model_terms:ir.ui.view,arch_db:odex_takaful.donations_details_lines_view_form
#, python-format
msgid "Extend Donation"
msgstr "تمديد التبرع"
msgstr "تمديد الكفالة"
#. module: odex_takaful
#: model:ir.model.fields.selection,name:odex_takaful.selection__donations_details_lines__state__extended

View File

@ -40,6 +40,8 @@ class DonationExtensionWizard(models.TransientModel):
store=True,
)
@api.depends('line_ids.total_donation_amount')
def _compute_total_extension_amount(self):
for rec in self:
@ -48,7 +50,7 @@ class DonationExtensionWizard(models.TransientModel):
@api.constrains('is_different_payment', 'payment_line_ids')
def _check_payment_sum_when_different(self):
for rec in self:
if rec.is_different_payment:
if not rec.is_different_payment:
sum_payments = sum(line.payment_amount for line in rec.payment_line_ids)
if float_compare(sum_payments, rec.total_extension_amount, precision_digits=2) != 0:
raise ValidationError(_("Total payment amounts (%s) must equal total extension amount (%s).") %
@ -75,7 +77,20 @@ class DonationExtensionWizard(models.TransientModel):
for rec in self:
if rec.months <= 0:
raise ValidationError(_("Extension months must be greater than 0."))
@api.onchange('payment_line_ids', 'total_extension_amount')
def _compute_lines(self):
remaining = self.total_extension_amount
for line in self.payment_line_ids:
if not line.payment_amount:
line.payment_amount = remaining
remaining -= line.payment_amount
line.remaining = remaining if remaining > 0 else 0
def action_extend(self):
"""
Extend the donation detail line with new amount and months
@ -88,7 +103,7 @@ class DonationExtensionWizard(models.TransientModel):
invoice_ids += result[0]
donation_line_ids += result[1]
if invoice_ids and self.is_different_payment:
if invoice_ids and not self.is_different_payment:
invoices = invoice_ids.filtered(
lambda inv: inv.state == 'posted' and inv.move_type in ('out_invoice', 'out_refund'))
if not invoices:
@ -121,10 +136,10 @@ class DonationExtensionWizard(models.TransientModel):
payment_register_vals = {
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': pay_line.partner_id.id,
'partner_id': inv.partner_id.id,
'amount': pay_amount,
'journal_id': pay_line.journal_id.id,
'payment_method_id': pay_line.payment_method.id,
# 'payment_method_id': pay_line.payment_method.id,
'communication': _("Extension Payment for %s") % inv.name,
'transaction_file_attachment': pay_line.payment_file_attachment,
@ -150,22 +165,22 @@ class DonationExtensionWizard(models.TransientModel):
remaining = remaining - pay_amount
elif invoice_ids and not self.is_different_payment:
return {
'name': _('Register Payment'),
'res_model': 'account.payment.register',
'view_mode': 'form',
'context': {
'active_model': 'account.move',
'active_ids': invoice_ids.ids,
'dont_redirect_to_payments': True,
'sponsorship_line_ids': donation_line_ids.ids,
'sponsorship_payment': True,
'default_sponsorship_payment': True,
},
'target': 'new',
'type': 'ir.actions.act_window',
}
# elif invoice_ids and not self.is_different_payment:
# return {
# 'name': _('Register Payment'),
# 'res_model': 'account.payment.register',
# 'view_mode': 'form',
# 'context': {
# 'active_model': 'account.move',
# 'active_ids': invoice_ids.ids,
# 'dont_redirect_to_payments': True,
# 'sponsorship_line_ids': donation_line_ids.ids,
# 'sponsorship_payment': True,
# 'default_sponsorship_payment': True,
# },
# 'target': 'new',
# 'type': 'ir.actions.act_window',
# }
return {
'type': 'ir.actions.client',
@ -216,6 +231,8 @@ class ExtensionPaymentWizardLine(models.TransientModel):
payment_amount = fields.Float(string='Payment Amount',
help="Amount to be paid for this line (when different payments used).",
default=0.0)
remaining = fields.Float(string="Remaining", readonly=True)
currency_id = fields.Many2one('res.currency', string='Currency',
default=lambda self: self.env.company.currency_id, readonly=True)
payment_method_type= fields.Selection(related='payment_method.payment_method')
@ -230,6 +247,15 @@ class ExtensionPaymentWizardLine(models.TransientModel):
if self.wizard_id and not self.donation_line_ids:
self.donation_line_ids = self.wizard_id.line_ids.mapped('donation_line_id').ids
# @api.onchange('payment_amount')
# def _onchange_payment_amount(self):
# amount = 0.0
# for line in self.wizard_id.payment_line_ids:
# amount += line.payment_amount
# self.payment_amount = self.wizard_id.total_extension_amount - amount
@api.depends('donation_line_ids')
def _compute_partner_id(self):
for rec in self:

View File

@ -10,7 +10,7 @@
<group>
<group string="Extension Details">
<field name="months"/>
<field name="is_different_payment"/>
<!-- <field name="is_different_payment"/>-->
</group>
</group>
<notebook>
@ -78,8 +78,8 @@
</form>
</field>
</page>
<page string="Sub Payments" attrs="{'invisible': [('is_different_payment', '=', False)]}">
<field name="payment_line_ids" attrs="{'invisible': [('is_different_payment', '=', False)]}" nolabel="1">
<page string="Sub Payments" >
<field name="payment_line_ids" nolabel="1">
<tree editable="bottom" delete="true" create="true">
<field name="payment_method" options="{'no_create': True, 'no_create_edit': True}"/>
<field name="currency_id" invisible="1"/>
@ -88,7 +88,7 @@
<field name="partner_id" invisible="1"/>
<field name="journal_id" string="Association Journal"/>
<field name="payment_amount" widget="monetary"
options="{'currency_field': 'currency_id'}" force_save="1"/>
options="{'currency_field': 'currency_id'}" force_save="1" sum="Total Amount"/>
<field name="check_number"
attrs="{
'invisible': [