fix issues in getting accounts
This commit is contained in:
parent
d8c21e9950
commit
7f312b37d6
|
|
@ -6,8 +6,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-09-12 02:30+0000\n"
|
||||
"PO-Revision-Date: 2024-09-12 02:30+0000\n"
|
||||
"POT-Creation-Date: 2024-09-12 03:26+0000\n"
|
||||
"PO-Revision-Date: 2024-09-12 03:26+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
|
@ -1288,7 +1288,9 @@ msgstr "جميع المصاريف"
|
|||
msgid ""
|
||||
"All selected benefits should be either state of "
|
||||
"'second_approve','temporarily_suspend','suspend' state."
|
||||
msgstr "كل الاسر المحددة يجب أن تكون في حالة 'الموافقة الثانية' أو 'التعليق المؤقت' أو 'التعليق'."
|
||||
msgstr ""
|
||||
"كل الاسر المحددة يجب أن تكون في حالة 'الموافقة الثانية' أو 'التعليق المؤقت' "
|
||||
"أو 'التعليق'."
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,help:odex_benefit.field_benefits_representative__lang
|
||||
|
|
@ -2551,6 +2553,12 @@ msgstr "مصاريف الاسرة"
|
|||
msgid "Cash Expense Account"
|
||||
msgstr "حساب مصاريف الاسرة"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/family_validation_setting.py:0
|
||||
#, python-format
|
||||
msgid "Cash Expense should be positive if cash account selected"
|
||||
msgstr "يجب ان تكون مصاريف النقدية ايجابية اذا تم اختيار الحساب النقدي"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model,name:odex_benefit.model_needs_categories
|
||||
msgid "Categories of need of benefit "
|
||||
|
|
@ -2715,6 +2723,12 @@ msgstr "مصاريف الكساء"
|
|||
msgid "Clothing Expense Account"
|
||||
msgstr "حساب مصاريف الكساء"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/family_validation_setting.py:0
|
||||
#, python-format
|
||||
msgid "Clothing Expense should be positive if clothing account selected"
|
||||
msgstr "يجب ان تكون مصاريف الكساء ايجابية اذا تم اختيار حساب الكساء"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_expenses__expenses_type__clothing
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__expenses_line__expenses_type__clothing
|
||||
|
|
@ -6663,6 +6677,12 @@ msgstr "مصاريف الغذاء"
|
|||
msgid "Meal Expense Account"
|
||||
msgstr "حساب مصاريف الغذاء"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/family_validation_setting.py:0
|
||||
#, python-format
|
||||
msgid "Meal Expense should be positive if meal account selected"
|
||||
msgstr "يجب أن تكون مصاريف الغذاء إيجابية إذا تم اختيار حساب الغذاء"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_family_validation_setting__meal_partner_id
|
||||
msgid "Meal Partner"
|
||||
|
|
@ -7979,6 +7999,12 @@ msgstr ""
|
|||
msgid "Please Upload More Than One Image"
|
||||
msgstr ""
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/wizards/family_expense_move_wiz.py:0
|
||||
#, python-format
|
||||
msgid "Please configure the expense accounts in the validation settings."
|
||||
msgstr "برجاء تكوين حسابات المصروفات فى اعدادات الاسر"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_benefits_representative__pos_order_ids
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_external_benefits__pos_order_ids
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
from odoo import fields, models
|
||||
from odoo import fields, models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class FamilyValidationSetting(models.Model):
|
||||
_name = 'family.validation.setting'
|
||||
|
|
@ -23,7 +25,21 @@ class FamilyValidationSetting(models.Model):
|
|||
clothing_expense_account_id = fields.Many2one('account.account', string='Clothing Expense Account',
|
||||
domain=[('deprecated', '=', False), ('internal_type', '=', 'other')])
|
||||
|
||||
benefit_category_ids = fields.Many2many(comodel_name='benefit.category',relation='benefit_category_family_validation_rel',
|
||||
column1='family_id',column2='categ_id', string='Benefit Categories')
|
||||
benefit_category_ids = fields.Many2many(comodel_name='benefit.category',
|
||||
relation='benefit_category_family_validation_rel',
|
||||
column1='family_id', column2='categ_id', string='Benefit Categories')
|
||||
|
||||
meal_partner_id = fields.Many2one('res.partner', string='Meal Partner')
|
||||
meal_partner_id = fields.Many2one('res.partner', string='Meal Partner')
|
||||
|
||||
@api.constrains('meal_expense_account_id', 'clothing_expense_account_id', 'cash_expense_account_id')
|
||||
def _constraint_amount_should_be_positive_if_account_selected(self):
|
||||
for rec in self:
|
||||
if rec.meal_expense_account_id:
|
||||
if rec.meal_expense <= 0:
|
||||
raise ValidationError(_('Meal Expense should be positive if meal account selected'))
|
||||
if rec.clothing_expense_account_id:
|
||||
if rec.clothing_expense <= 0:
|
||||
raise ValidationError(_('Clothing Expense should be positive if clothing account selected'))
|
||||
if rec.cash_expense_account_id:
|
||||
if rec.cash_expense <= 0:
|
||||
raise ValidationError(_('Cash Expense should be positive if cash account selected'))
|
||||
|
|
|
|||
|
|
@ -18,20 +18,21 @@ class ConfirmBenefitWizard(models.TransientModel):
|
|||
active_ids = self.env.context.get('default_benefit_ids', [])
|
||||
benefits = self.env['grant.benefit'].browse(active_ids)
|
||||
|
||||
if any(benefit.state not in ('second_approve', 'temporarily_suspend', 'suspend') for benefit in benefits):
|
||||
if any(benefit.state not in ('second_approve', 'temporarily_suspend', 'suspend') for benefit in benefits):
|
||||
raise UserError(_("All selected benefits should be either state of "
|
||||
"'second_approve','temporarily_suspend','suspend' state."))
|
||||
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
inbound_line_ids = self.journal_id.inbound_payment_method_line_ids.filtered(lambda l: l.payment_method_id == self.payment_method_id.id)
|
||||
outbound_line_ids = self.journal_id.outbound_payment_method_line_ids.filtered(lambda l: l.payment_method_id == self.payment_method_id.id)
|
||||
credit_account_id=False
|
||||
if not inbound_line_ids and not outbound_line_ids:
|
||||
|
||||
payment_method_line = self.env['account.payment.method.line'].search(
|
||||
[('payment_method_id', '=', self.payment_method_id.id)], limit=1)
|
||||
|
||||
if not validation_setting.cash_expense_account_id or not validation_setting.meal_expense_account_id or not validation_setting.clothing_expense_account_id:
|
||||
raise UserError(_("Please configure the expense accounts in the validation settings."))
|
||||
if not payment_method_line:
|
||||
raise UserError(_("Payment method is not configured for the selected journal."))
|
||||
if inbound_line_ids:
|
||||
credit_account_id = inbound_line_ids[0].payment_account_id.id
|
||||
if not credit_account_id and outbound_line_ids:
|
||||
credit_account_id = outbound_line_ids[0].payment_account_id.id
|
||||
|
||||
credit_account_id = payment_method_line.payment_account_id.id
|
||||
|
||||
if not credit_account_id:
|
||||
raise UserError(_("Payment method is not configured for the selected journal."))
|
||||
|
|
|
|||
Loading…
Reference in New Issue