diff --git a/odex25_accounting/account_budget_custom/__init__.py b/odex25_accounting/account_budget_custom/__init__.py old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/__manifest__.py b/odex25_accounting/account_budget_custom/__manifest__.py old mode 100644 new mode 100755 index d516d42f5..154e8cccd --- a/odex25_accounting/account_budget_custom/__manifest__.py +++ b/odex25_accounting/account_budget_custom/__manifest__.py @@ -8,9 +8,9 @@ """, 'author': "Expert Co. Ltd.", 'website': "http://www.exp-sa.com", - 'category': 'Odex25-Accounting/Odex25-Accounting', + 'category': 'Odex25 Accounting/Accounting', # any module necessary for this one to work correctly - 'depends': ['base','odex25_account_budget', 'odex25_account_reports', 'report_xlsx'], + 'depends': ['odex25_account_budget', 'odex25_account_reports', 'report_xlsx'], # always loaded 'data': [ 'data/budget_operation_data.xml', diff --git a/odex25_accounting/account_budget_custom/data/budget_operation_data.xml b/odex25_accounting/account_budget_custom/data/budget_operation_data.xml old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/i18n/ar_001.po b/odex25_accounting/account_budget_custom/i18n/ar_001.po index a9845b10e..4c55e7ff5 100644 --- a/odex25_accounting/account_budget_custom/i18n/ar_001.po +++ b/odex25_accounting/account_budget_custom/i18n/ar_001.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-08 11:11+0000\n" -"PO-Revision-Date: 2024-05-08 11:11+0000\n" +"POT-Creation-Date: 2024-06-26 18:41+0000\n" +"PO-Revision-Date: 2024-06-26 18:41+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -66,9 +66,40 @@ msgstr "السماح بتخطي الموازنة" #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__total_amount #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation_line__amount #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__amount +#: model_terms:ir.ui.view,arch_db:account_budget_custom.view_budget_operations msgid "Amount" msgstr "مبلغ" +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/account_budget.py:0 +#: model:ir.model.fields,help:account_budget_custom.field_crossovered_budget_lines__above_remain +#, python-format +msgid "Amount of money that has been exceeded" +msgstr "" +" هي المبالغ التي تم صرفها بعد انتهاء رصيد المتبقى من الموازنة في حالة " +"التجاوز الموازنة" + +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/account_budget.py:0 +#: model:ir.model.fields,help:account_budget_custom.field_crossovered_budget_lines__provide +#, python-format +msgid "Amount of money that has been provided" +msgstr "تعزيز او تحويل من هو عبارة عن تعزيزات الموازنة او تحويلات من موزانات أخرى" + +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/account_budget.py:0 +#: model:ir.model.fields,help:account_budget_custom.field_crossovered_budget_lines__pull_out +#, python-format +msgid "Amount of money that has been pulled out" +msgstr "تخفيض او تحويل الى هو عبارة عن تخفيضات للموازنة او تحويلات الى موزانات أخرى" + +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/account_budget.py:0 +#: model:ir.model.fields,help:account_budget_custom.field_crossovered_budget_lines__remain +#, python-format +msgid "Amount of money that has been remained" +msgstr " ( مبلغ متاح - المبلغ المحجوز - مبلغ تعميد - المبلغ الفعلى - المحجوز المبدئي ) يكون صفر عند قابل الاشارة" + #. module: account_budget_custom #: model_terms:ir.ui.view,arch_db:account_budget_custom.view_budget_confirmation_form msgid "Approve" @@ -88,6 +119,7 @@ msgstr "المستفيد" #. module: account_budget_custom #: model:ir.model,name:account_budget_custom.model_crossovered_budget +#: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation_line__crossovered_budget_id #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__from_crossovered_budget_id #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__to_crossovered_budget_id msgid "Budget" @@ -131,6 +163,7 @@ msgstr "بند الموازنة" #. module: account_budget_custom #: code:addons/account_budget_custom/reports/budget_report_xlsx.py:0 +#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget__crossovered_budget_line #: model_terms:ir.ui.view,arch_db:account_budget_custom.view_crossovered_budget_line_graph #: model_terms:ir.ui.view,arch_db:account_budget_custom.view_crossovered_budget_line_pivot #: model_terms:ir.ui.view,arch_db:account_budget_custom.view_crossovered_budget_line_tree @@ -199,15 +232,21 @@ msgid "Budget XLSX Report" msgstr "تقرير الموازنة (اكسل)" #. module: account_budget_custom -#: model:ir.model,name:account_budget_custom.model_account_budget_post -msgid "Budgetary Position" -msgstr "بند الموازنة" +#: code:addons/account_budget_custom/models/account_budget.py:0 +#, python-format +msgid "Budget lines can not be overlaped with another." +msgstr "لا يمكن تراكب خطوط الميزانية مع بعضها البعض." #. module: account_budget_custom #: model:ir.ui.menu,name:account_budget_custom.main_budgets_menu msgid "Budgets" msgstr "الموازنات" +#. module: account_budget_custom +#: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__bybass_budget_check +msgid "ByPass Budget Line Check" +msgstr "تخطي ربط الموازنه بالحساب" + #. module: account_budget_custom #: model:ir.model.fields.selection,name:account_budget_custom.selection__budget_confirmation__state__cancel msgid "Cancel" @@ -239,21 +278,16 @@ msgstr "" msgid "Confirm" msgstr "تأكيد" -#. module: account_budget_custom -#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__confirm -msgid "Confirm Amount" -msgstr "المبلغ المصدق" - -#. module: account_budget_custom -#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__budget_confirm_amount -msgid "Confirmation Amount" -msgstr "مبلغ التصديق" - #. module: account_budget_custom #: model:ir.model.fields.selection,name:account_budget_custom.selection__budget_operations__state__confirmed msgid "Confirmed" msgstr "مؤكد" +#. module: account_budget_custom +#: model:ir.model,name:account_budget_custom.model_res_partner +msgid "Contact" +msgstr "جهة الاتصال" + #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__analytic_account_id #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation_line__analytic_account_id @@ -325,9 +359,12 @@ msgstr "تفاصيل المطابقة" #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__display_name #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation_line__display_name #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__display_name +#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget__display_name +#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__display_name #: model:ir.model.fields,field_description:account_budget_custom.field_reject_wizard__display_name #: model:ir.model.fields,field_description:account_budget_custom.field_report_account_budget_custom_budget_report__display_name #: model:ir.model.fields,field_description:account_budget_custom.field_report_account_budget_custom_budget_xslx_report__display_name +#: model:ir.model.fields,field_description:account_budget_custom.field_res_partner__display_name msgid "Display Name" msgstr "الاسم المعروض" @@ -346,12 +383,25 @@ msgstr "تم التعميد" msgid "Draft" msgstr "موظف الميزانية" +#. module: account_budget_custom +#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__above_remain +#: model_terms:ir.ui.view,arch_db:account_budget_custom.crossovered_budget_view_form +msgid "Exceed Amount" +msgstr "التجاوز الموازنة" + #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__final_amount #: model_terms:ir.ui.view,arch_db:account_budget_custom.crossovered_budget_view_form msgid "Final Amount" msgstr "المبلغ النهائي" +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/account_budget.py:0 +#: model:ir.model.fields,help:account_budget_custom.field_crossovered_budget_lines__final_amount +#, python-format +msgid "Final amount of money that has been provided" +msgstr "هو مبلغ الموازنة المتاح للارتباط ويشمل مبلغ المخطط + تعزيز او تحويل من - تخفيض او تحويل الى" + #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__message_follower_ids #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__message_follower_ids @@ -399,11 +449,14 @@ msgstr "من العملية" #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__id #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation_line__id #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__id +#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget__id +#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__id #: model:ir.model.fields,field_description:account_budget_custom.field_reject_wizard__id #: model:ir.model.fields,field_description:account_budget_custom.field_report_account_budget_custom_budget_report__id #: model:ir.model.fields,field_description:account_budget_custom.field_report_account_budget_custom_budget_xslx_report__id +#: model:ir.model.fields,field_description:account_budget_custom.field_res_partner__id msgid "ID" -msgstr "المرجع" +msgstr "المُعرف" #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__activity_exception_icon @@ -442,18 +495,16 @@ msgstr "تعزيز" msgid "Is Follower" msgstr "متابع" -#. module: account_budget_custom -#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__is_transfered -msgid "Is Transfered" -msgstr "" - #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation____last_update #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation_line____last_update #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations____last_update +#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget____last_update +#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines____last_update #: model:ir.model.fields,field_description:account_budget_custom.field_reject_wizard____last_update #: model:ir.model.fields,field_description:account_budget_custom.field_report_account_budget_custom_budget_report____last_update #: model:ir.model.fields,field_description:account_budget_custom.field_report_account_budget_custom_budget_xslx_report____last_update +#: model:ir.model.fields,field_description:account_budget_custom.field_res_partner____last_update msgid "Last Modified on" msgstr "آخر تعديل في" @@ -590,7 +641,7 @@ msgstr "المبلغ الفعلي" #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__provide msgid "Provide" -msgstr "الدعومات" +msgstr "تعزيز/تحويل من" #. module: account_budget_custom #: model_terms:ir.ui.view,arch_db:account_budget_custom.crossovered_budget_view_form @@ -601,7 +652,7 @@ msgstr "مبلغ الدعم" #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__pull_out msgid "Pull Out" -msgstr "تخفيض" +msgstr "تخفيض/تحويل إلي" #. module: account_budget_custom #: model_terms:ir.ui.view,arch_db:account_budget_custom.crossovered_budget_view_form @@ -612,29 +663,23 @@ msgstr "مبلغ السحب" #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__purchase_remain msgid "Purchase Remain" -msgstr "المتبقي من التعميد" +msgstr "المبلغ" #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__purchase_remind msgid "Purchase Remind" -msgstr "المتبقي من التعميد" +msgstr "المبلغ" #. module: account_budget_custom #: model:ir.model.fields.selection,name:account_budget_custom.selection__budget_confirmation__type__purchase_request msgid "Purchase Request" -msgstr "طلب شراء" +msgstr "" #. module: account_budget_custom #: model:ir.model.fields.selection,name:account_budget_custom.selection__budget_confirmation__type__purchase_order msgid "Purchase Requisition" msgstr "" -#. module: account_budget_custom -#: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__reason -#: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__reason -msgid "Reason/Justification" -msgstr "السببظ المبرر" - #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__ref msgid "Reference" @@ -648,10 +693,14 @@ msgstr "رفض" #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__reject_reason -#: model:ir.model.fields,field_description:account_budget_custom.field_reject_wizard__reject_reason msgid "Reject Reason" msgstr "سبب الرفض" +#. module: account_budget_custom +#: model:ir.model.fields,field_description:account_budget_custom.field_reject_wizard__reject_reason +msgid "Reject Reson" +msgstr "سبب الرفض" + #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation__res_model msgid "Related Document Model Name" @@ -660,7 +709,7 @@ msgstr "اسم كائن المستند المرتبط" #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_confirmation_line__remain msgid "Remain" -msgstr "الباقي" +msgstr "المبلغ المتاح" #. module: account_budget_custom #: model_terms:ir.ui.view,arch_db:account_budget_custom.crossovered_budget_view_form @@ -688,12 +737,6 @@ msgstr "التقارير" msgid "Request user" msgstr "المستخدم الطالب" -#. module: account_budget_custom -#: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__reserve -#: model_terms:ir.ui.view,arch_db:account_budget_custom.crossovered_budget_view_form -msgid "Reserve Amount" -msgstr "المبلغ المحجوز" - #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_budget_operations__from_reserved msgid "Reserve?" @@ -738,6 +781,12 @@ msgstr "" msgid "Sorry, No data to Print" msgstr "لا يوجد بيانات ليتم طباعتها" +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/account_budget.py:0 +#, python-format +msgid "Sources Sale Orders %s" +msgstr "" + #. module: account_budget_custom #: code:addons/account_budget_custom/models/budget_confirmation.py:0 #, python-format @@ -770,17 +819,26 @@ msgstr "" "اليوم: تاريخ النشاط هو اليوم\n" "المخطط: الأنشطة المستقبلية." +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/budget_operations.py:0 +#, python-format +msgid "The amount must be less than or equal to the budget line final amount" +msgstr "يجب ان يكون المبلغ اقل او يساوي المبلغ النهائي للبند الموازنة" + +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/budget_operations.py:0 +#: code:addons/account_budget_custom/models/budget_operations.py:0 +#: code:addons/account_budget_custom/models/budget_operations.py:0 +#: code:addons/account_budget_custom/models/budget_operations.py:0 +#, python-format +msgid "The date must be between the budget %s post period" +msgstr "يجب ان يكون التاريخ مقابل للفتره المحدده %s" + #. module: account_budget_custom #: model:ir.model.fields,field_description:account_budget_custom.field_crossovered_budget_lines__theoritical_amount msgid "Theoretical Amount" msgstr "القيمة النظرية" -#. module: account_budget_custom -#: code:addons/account_budget_custom/models/account_budget.py:0 -#, python-format -msgid "This position can not be deleted" -msgstr "لا يمكن حذف مركز موازنة" - #. module: account_budget_custom #: model_terms:ir.ui.view,arch_db:account_budget_custom.view_budget_operations msgid "To" @@ -812,6 +870,13 @@ msgstr "إجمالي المبلغ" msgid "Total amount in services request line" msgstr "المبلغ" +#. module: account_budget_custom +#: code:addons/account_budget_custom/models/account_budget.py:0 +#: model:ir.model.fields,help:account_budget_custom.field_crossovered_budget_lines__practical_amount +#, python-format +msgid "Total amount of money that has been spent" +msgstr "" + #. module: account_budget_custom #: model:ir.model.fields.selection,name:account_budget_custom.selection__budget_operations__operation_type__transfer #: model:ir.model.fields.selection,name:account_budget_custom.selection__budget_operations__type__transfer @@ -865,9 +930,10 @@ msgstr "نهاية السنة" #. module: account_budget_custom #: code:addons/account_budget_custom/models/budget_operations.py:0 +#: code:addons/account_budget_custom/models/budget_operations.py:0 #, python-format msgid "You can transfer to approved budget only" -msgstr "" +msgstr "يمكنك التحويل الى موازنة معتمدة فقط" #. module: account_budget_custom #: code:addons/account_budget_custom/models/account_budget.py:0 @@ -877,11 +943,6 @@ msgstr "لا يمكن حذف موازنة ليست في مرحلة مسودة" #. module: account_budget_custom #: code:addons/account_budget_custom/models/account_budget.py:0 -#, python-format -msgid "You can not take more than the remaining amount" -msgstr "لا يمكن أخذ أكثر من المبلغ المتبقي" - -#. module: account_budget_custom #: code:addons/account_budget_custom/models/account_budget.py:0 #, python-format msgid "You can not take more than the remaining amount.." @@ -985,8 +1046,13 @@ msgstr "" msgid "تاريخ البدء" msgstr "" +#. module: account_budget_custom +#: model_terms:ir.ui.view,arch_db:account_budget_custom.crossovered_budget_view_form +msgid "مبلغ نهائي" +msgstr "" + #. module: account_budget_custom #: code:addons/account_budget_custom/reports/budget_report_xlsx.py:0 #, python-format msgid "وضع المـوازنـة" -msgstr "" \ No newline at end of file +msgstr "بند المـوازنـة" diff --git a/odex25_accounting/account_budget_custom/models/__init__.py b/odex25_accounting/account_budget_custom/models/__init__.py old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/models/account_budget.py b/odex25_accounting/account_budget_custom/models/account_budget.py index 7738d5e91..b1dabdf19 100644 --- a/odex25_accounting/account_budget_custom/models/account_budget.py +++ b/odex25_accounting/account_budget_custom/models/account_budget.py @@ -2,14 +2,6 @@ from odoo import api, fields, models, _ from odoo.exceptions import UserError, ValidationError -class AccountBudgetPost(models.Model): - _inherit = "account.budget.post" - - def unlink(self): - raise ValidationError(_('This position can not be deleted')) - # return super(AccountBudgetPost, self).unlink() - - class CrossoveredBudget(models.Model): _inherit = "crossovered.budget" _order = "create_date desc" @@ -18,6 +10,7 @@ class CrossoveredBudget(models.Model): currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, required=True, default=lambda self: self.env.user.company_id.currency_id.id) + crossovered_budget_line = fields.One2many(copy=False) def unlink(self): for budget in self: @@ -25,36 +18,114 @@ class CrossoveredBudget(models.Model): raise UserError(_('You can not delete budget not in draft state')) return super(CrossoveredBudget, self).unlink() + def copy(self, default=None): + default = dict(default or {}) + default.update({ + 'name': self.name + ' (copy)', + 'state': 'draft', + }) + return super(CrossoveredBudget, self).copy(default) + + # check that budget period doesn't overlap with another budget + @api.constrains('crossovered_budget_line', 'date_from', 'date_to') + def _check_budget_line_period(self): + for budget in self: + if budget.state == 'done': + continue + for line in budget.crossovered_budget_line: + domain = [ + ('crossovered_budget_id.date_from', '<=', budget.date_to), + ('crossovered_budget_id.date_to', '>=', budget.date_from), + ('crossovered_budget_id.state', '=', 'done'), + ('id', '!=', line.id), + ('analytic_account_id', '=', line.analytic_account_id.id), + ('general_budget_id', '=', line.general_budget_id.id), + ] + if self.env['crossovered.budget.lines'].search_count(domain): + raise ValidationError(_('Budget lines can not be overlaped with another.')) + class CrossoveredBudgetLines(models.Model): _inherit = "crossovered.budget.lines" reserved_percent = fields.Float(related='crossovered_budget_id.reserved_percent', string='Reserved Percent') reserved_amount = fields.Float(string='Reserved Amount', readonly=True, compute='_compute_reserved_amount') - # pull_out = fields.Float(string='Pull Out', compute='_compute_operations_amount', store=True, tracking=True) - pull_out = fields.Monetary(string='Pull Out') + pull_out = fields.Monetary(string='Pull Out', compute='_compute_pull_out', + help=_('Amount of money that has been pulled out'),store=True) - provide = fields.Float(string='Provide', compute='_compute_operations_amount', store=True) - remain = fields.Float(string='Remain of Christening', compute='_compute_operations_amount') - budget_confirm_amount = fields.Float(string='Confirmation Amount', compute='_compute_operations_amount') + provide = fields.Float(string='Provide', compute='_compute_provide', + help=_('Amount of money that has been provided'),store=True) + + remain = fields.Float(string='Remain of Christening', compute='_compute_remain',help=_('Amount of money that has been remained')) + above_remain = fields.Float(string='Exceed Amount', compute='_compute_remain', + help=_('Amount of money that has been exceeded')) purchase_remain = fields.Float(store=True) practical_amount = fields.Float(compute='_compute_practical_amount', string='Practical Amount', digits=0, - store=False) + store=False, help=_('Total amount of money that has been spent')) theoritical_amount = fields.Float(compute='_compute_theoritical_amount', string='Theoretical Amount', digits=0, store=True) percentage = fields.Float(compute='_compute_percentage', string='Achievement', store=False, digits=(16, 4)) from_operation_ids = fields.One2many('budget.operations', 'from_budget_line_id', string='From Operation') to_operation_ids = fields.One2many('budget.operations', 'to_budget_line_id', string='Cost Center') - reserve = fields.Float(string='Last Reserve Amount') - confirm = fields.Float(string='Confirm Amount') year_end = fields.Boolean(compute="get_year_end") - is_transfered = fields.Boolean(default=False) - final_amount = fields.Float(compute='_compute_final_amount') - @api.depends('planned_amount', 'pull_out', 'provide') + final_amount = fields.Float(string='Final Amount', compute='_compute_final_amount', + help=_('Final amount of money that has been provided'),store=True) + + reserve = fields.Float(string='Reserve Amount', compute='_compute_reserve', + help=_('Total amount of reserved purchase orders')) + + confirm = fields.Float(string='Confirm Amount', compute='_compute_confirm', + help=_('Total amount of confirmed purchase orders')) + + @api.depends('analytic_account_id') + def _compute_confirm(self): + for rec in self: + orders = self.env['purchase.order.line'].search( + [('account_analytic_id', '=', rec.analytic_account_id.id), + ('order_id.state', 'in', ['purchase'])]).mapped('order_id') + total_orders = sum(orders.mapped('amount_total')) + invoiced = self.env['account.move'].search( + [('purchase_id', 'in', orders.ids), ('state', 'not in', ['draft', 'cancel'])]).mapped('amount_total') + rec.confirm = (total_orders - sum(invoiced)) * -1 + + @api.depends('analytic_account_id') + def _compute_reserve(self): + for rec in self: + orders = self.env['purchase.order.line'].search( + [('account_analytic_id', '=', rec.analytic_account_id.id), + ('order_id.state', 'in', ['draft', 'sent', 'to approve'])]).mapped('order_id') + total_orders = sum(orders.mapped('amount_total')) + rec.reserve = total_orders * -1 + + @api.depends('planned_amount', 'provide', 'pull_out') def _compute_final_amount(self): + for rec in self: + rec.final_amount = rec.planned_amount + rec.provide + rec.pull_out + + @api.depends('from_operation_ids') + def _compute_pull_out(self): for line in self: - line.final_amount = line.planned_amount + line.provide - line.pull_out + pull_out = sum(op.amount + op.purchase_remind for op in + line.from_operation_ids.filtered(lambda x: x.state == 'confirmed') if + op.operation_type == 'transfer' or op.operation_type == 'decrease') + line.pull_out = pull_out if line.planned_amount < 0 else pull_out * -1 + + @api.depends('to_operation_ids') + def _compute_provide(self): + for line in self: + provide = sum(op.amount + op.purchase_remind for op in + line.to_operation_ids.filtered(lambda x: x.state == 'confirmed') if + op.operation_type == 'transfer' or op.operation_type == 'increase') + line.provide = provide * -1 if line.planned_amount < 0 else provide + + @api.depends('to_operation_ids', 'from_operation_ids') + def _compute_remain(self): + for line in self: + remain_value = ((abs(line.final_amount) - abs(line.reserve) - abs(line.confirm) - abs( + line.practical_amount)) * -1) + line.remain = 0 if remain_value > 0 else remain_value + line.above_remain = remain_value if remain_value > 0 else 0 def get_year_end(self): for rec in self: @@ -85,69 +156,6 @@ class CrossoveredBudgetLines(models.Model): } } - @api.depends('from_operation_ids', 'to_operation_ids') - def _compute_operations_amount(self): - if not self.ids: return - for line in self: - pull_out = provide = budget_confirm_amount = purchase_remind = reserve_amount = 0.0 - date_to = self.env.context.get('wizard_date_to') or line.date_to - date_from = self.env.context.get( - 'wizard_date_from') or line.date_from - - if line.analytic_account_id.id: - if 'reserved' not in self.env.context: - self.env.cr.execute(""" - SELECT SUM(amount) - FROM budget_operations - WHERE from_budget_line_id=%s - AND (date between %s AND %s) - AND state='confirmed'""", - (line._origin.id, date_from, date_to,)) - pull_out = self.env.cr.fetchone()[0] or 0.0 - - if 'reserved' in self.env.context: - self.env.cr.execute(""" - SELECT SUM(amount) - FROM budget_operations - WHERE from_budget_line_id=%s - AND (date between %s AND %s) - AND state='confirmed' - AND from_reserved=%s""", - (line._origin.id, date_from, date_to, self.env.context['reserved'])) - pull_out = self.env.cr.fetchone()[0] or 0.0 - - self.env.cr.execute(""" - SELECT SUM(amount) - FROM budget_operations - WHERE to_budget_line_id=%s - AND (date between %s AND %s) - AND state='confirmed'""", - (line._origin.id, date_from, date_to,)) - provide = self.env.cr.fetchone()[0] or 0.0 - - self.env.cr.execute(""" - SELECT SUM(purchase_remind) - FROM budget_operations - WHERE to_budget_line_id=%s - AND (date between %s AND %s) - AND state='confirmed'""", - (line._origin.id, date_from, date_to,)) - reserve_amount = self.env.cr.fetchone()[0] or 0.0 - - self.env.cr.execute(""" - SELECT SUM(amount) - FROM budget_confirmation_line - WHERE budget_line_id=%s - AND (date between %s AND %s) - AND state='done'""", - (line._origin.id, date_from, date_to,)) - budget_confirm_amount = self.env.cr.fetchone()[0] or 0.0 - - line.provide = provide - line.budget_confirm_amount = budget_confirm_amount - # line.remain = line.planned_amount + provide + line.pull_out - line.practical_amount + line.reserve + line.purchase_remain - line.remain = line.final_amount - line.practical_amount - @api.depends('analytic_account_id', 'planned_amount', 'practical_amount') def name_get(self): result = [] @@ -155,13 +163,7 @@ class CrossoveredBudgetLines(models.Model): for line in self: name = '' name += line.analytic_account_id and line.analytic_account_id.name or '' + ' ' + _('remaining') + ' ' - - # check if reserved is needed - if self.env.context.get('reserved', False): - name += str(line.reserved_amount) - - if not self.env.context.get('reserved', False): - name += str(line.remain) + name += str(line.final_amount) result.append((line.id, name)) return result @@ -215,20 +217,41 @@ class CrossoveredBudgetLines(models.Model): def _check_amount(self, amount=0, purchase_remind=0, transfer=False): for obj in self: - if self.from_operation_ids.operation_type=='transfer' and self.from_operation_ids.purchase_remind>obj.final_amount: - raise ValidationError(_('''You can not take more than the remaining amount..''')) - # if obj.purchase_remain> - reserved_amount = obj.crossovered_budget_id.reserved_percent * \ obj.planned_amount / 100.0 + if obj.with_context({'reserved': True}).pull_out > reserved_amount: raise ValidationError( _('''You can not take more than the reserved amount.''')) - if obj.planned_amount < 0: - if transfer and obj.purchase_remain != purchase_remind: - raise ValidationError(_('''You can not take more than the remaining amount..''')) - else: - if abs(obj.remain) < amount or obj.purchase_remain < purchase_remind: - raise ValidationError( - _('''You can not take more than the remaining amount''')) + if transfer and abs(obj.remain) < abs(purchase_remind): + raise ValidationError( + _('''You can not take more than the remaining amount..''')) + + if amount and amount > obj.remain: + raise ValidationError( + _('''You can not take more than the remaining amount..''')) + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + def action_view_sale_orders(self): + self.ensure_one() + sale_order_ids = self._get_sale_orders().ids + action = { + 'res_model': 'sale.order', + 'type': 'ir.actions.act_window', + } + if len(sale_order_ids) == 1: + action.update({ + 'view_mode': 'form', + 'res_id': sale_order_ids[0], + }) + else: + action.update({ + 'name': _('Sources Sale Orders %s', self.name), + 'domain': [('id', 'in', sale_order_ids)], + 'view_mode': 'tree,form', + }) + return action diff --git a/odex25_accounting/account_budget_custom/models/budget_confirmation.py b/odex25_accounting/account_budget_custom/models/budget_confirmation.py old mode 100644 new mode 100755 index d02406d9f..117cd49f2 --- a/odex25_accounting/account_budget_custom/models/budget_confirmation.py +++ b/odex25_accounting/account_budget_custom/models/budget_confirmation.py @@ -198,6 +198,11 @@ class BudgetConfirmationLine(models.Model): description = fields.Text( string='Description' ) + crossovered_budget_id = fields.Many2one( + comodel_name='crossovered.budget', + string='Budget', + related='budget_line_id.crossovered_budget_id', + ) def check_budget(self): """ @@ -245,4 +250,8 @@ class RejectWizard(models.TransientModel): raise ValidationError(_('Sorry This object have no field named Selection Reason')) else: origin_rec.write({'reject_reason': self.reject_reason}) + if origin_rec.po_id: + origin_rec.po_id.message_post(body=self.reject_reason) + if origin_rec.invoice_id: + origin_rec.invoice_id.message_post(body=self.reject_reason) return origin_rec.with_context({'reject_reason': self.reject_reason}).cancel() \ No newline at end of file diff --git a/odex25_accounting/account_budget_custom/models/budget_operations.py b/odex25_accounting/account_budget_custom/models/budget_operations.py old mode 100644 new mode 100755 index 27a793e67..8bdee11eb --- a/odex25_accounting/account_budget_custom/models/budget_operations.py +++ b/odex25_accounting/account_budget_custom/models/budget_operations.py @@ -20,21 +20,21 @@ class BudgetOperations(models.Model): name = fields.Char(string='Name', default='/') department_id = fields.Many2one(comodel_name='hr.department', string='Department') - from_crossovered_budget_id = fields.Many2one(comodel_name='crossovered.budget', string='Budget', tracking=True) - from_budget_line_id = fields.Many2one(comodel_name='crossovered.budget.lines', string='Cost Center', tracking=True) - to_crossovered_budget_id = fields.Many2one(comodel_name='crossovered.budget', string='Budget', tracking=True) - to_budget_line_id = fields.Many2one(comodel_name='crossovered.budget.lines', string='Cost Center', tracking=True) + from_crossovered_budget_id = fields.Many2one(comodel_name='crossovered.budget', string='Budget', tracking=True,copy=False) + from_budget_line_id = fields.Many2one(comodel_name='crossovered.budget.lines', string='Cost Center', tracking=True,copy=False) + to_crossovered_budget_id = fields.Many2one(comodel_name='crossovered.budget', string='Budget', tracking=True,copy=False) + to_budget_line_id = fields.Many2one(comodel_name='crossovered.budget.lines', string='Cost Center', tracking=True,copy=False) amount = fields.Monetary(string='Amount', tracking=True) currency_id = fields.Many2one(comodel_name='res.currency', string='Currency', readonly=True, required=True, default=lambda self: self.env.user.company_id.currency_id.id) state = fields.Selection(selection=[('draft', 'Draft'), ('confirmed', 'Confirmed')], - default='draft', string='Status', readonly=True, tracking=True) + default='draft', string='Status', readonly=True, tracking=True,copy=False) type = fields.Selection(selection=[('unlock', 'Unlock'), ('transfer', 'Transfer')], default='transfer', string='type', readonly=True, tracking=True) date = fields.Date() - from_reserved = fields.Boolean(string='Reserve?', tracking=True) - from_budget_post_id = fields.Many2one(comodel_name='account.budget.post', string='Budget Post', tracking=True) - to_budget_post_id = fields.Many2one(comodel_name='account.budget.post', string='Budget Post', tracking=True) + from_reserved = fields.Boolean(string='Reserve?', tracking=True,copy=False) + from_budget_post_id = fields.Many2one(comodel_name='account.budget.post', string='Budget Post', tracking=True,copy=False) + to_budget_post_id = fields.Many2one(comodel_name='account.budget.post', string='Budget Post', tracking=True,copy=False) operation_type = fields.Selection( selection=[('transfer', 'Transfer'), ('increase', 'Increase'), ('decrease', 'Decrease')], default='transfer', string='Operation Type', required=True, tracking=True) @@ -68,6 +68,18 @@ class BudgetOperations(models.Model): self.from_budget_post_id = False self.from_reserved = False + @api.onchange('from_crossovered_budget_id', 'to_crossovered_budget_id', 'date') + def _onchange_budget_check_period(self): + if self.from_crossovered_budget_id and self.date: + if self.from_crossovered_budget_id.date_from > self.date or self.from_crossovered_budget_id.date_to < self.date: + raise ValidationError( + _('The date must be between the budget %s post period') % (self.from_crossovered_budget_id.name)) + + if self.to_crossovered_budget_id and self.date: + if self.to_crossovered_budget_id.date_from > self.date or self.to_crossovered_budget_id.date_to < self.date: + raise ValidationError( + _('The date must be between the budget %s post period') % (self.from_crossovered_budget_id.name)) + @api.onchange('from_budget_post_id') def _onchange_from_budget_post(self): domain = [('id', 'in', [])] @@ -86,7 +98,7 @@ class BudgetOperations(models.Model): if self.to_budget_post_id: budget_line_obj = self.env['crossovered.budget.lines'] search_domain = [('general_budget_id', '=', self.to_budget_post_id.id)] - if self.operation_type == 'transfer' and self.from_crossovered_budget_id: + if self.operation_type == 'transfer' and self.from_crossovered_budget_id.date_to: search_domain += [('date_to', '>', str(self.from_crossovered_budget_id.date_to))] budget_line = budget_line_obj.search(search_domain) domain = [('id', 'in', budget_line.mapped('crossovered_budget_id').ids)] @@ -118,25 +130,26 @@ class BudgetOperations(models.Model): self.state = 'draft' def confirm(self): - """ - """ - if self.date and self.to_crossovered_budget_id: + if self.from_crossovered_budget_id and self.date and self.operation_type in ['transfer', 'decrease']: + if self.from_crossovered_budget_id.date_from > self.date or self.from_crossovered_budget_id.date_to < self.date: + raise ValidationError( + _('The date must be between the budget %s post period') % (self.from_crossovered_budget_id.name)) - budget_start_date = self.to_crossovered_budget_id.date_from - budget_end_date = self.to_crossovered_budget_id.date_to + if self.to_crossovered_budget_id and self.date and self.operation_type in ['transfer', 'increase']: + if self.to_crossovered_budget_id.date_from > self.date or self.to_crossovered_budget_id.date_to < self.date: + raise ValidationError( + _('The date must be between the budget %s post period') % (self.from_crossovered_budget_id.name)) - - if self.date < budget_start_date or self.date > budget_end_date: - raise ValidationError(_('The operation date must be within the budget duration.')) - if self.to_crossovered_budget_id and self.to_crossovered_budget_id.state != 'done': + if self.to_crossovered_budget_id.state != 'done' and self.operation_type in ['transfer', 'increase']: raise ValidationError( _('You can transfer to approved budget only')) - self.to_budget_line_id.pull_out = self.purchase_remind - transfer = True if self.operation_type == 'transfer' else False - self.from_budget_line_id._check_amount(self.amount, self.purchase_remind, transfer) - # self.from_budget_line_id.is_transfered = True - if self.type == 'unlock': - self.from_reserved = True - self.to_crossovered_budget_id = self.from_crossovered_budget_id.id - self.to_budget_line_id = self.from_budget_line_id.id + + if self.from_crossovered_budget_id.state != 'done' and self.operation_type in ['transfer', 'decrease']: + raise ValidationError( + _('You can transfer to approved budget only')) + + if self.operation_type=='transfer': + if abs(self.from_budget_line_id.final_amount) < abs(self.purchase_remind): + raise ValidationError( + _('The amount must be less than or equal to the budget line final amount')) self.state = 'confirmed' diff --git a/odex25_accounting/account_budget_custom/reports/__init__.py b/odex25_accounting/account_budget_custom/reports/__init__.py old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/reports/budget_report_xlsx.py b/odex25_accounting/account_budget_custom/reports/budget_report_xlsx.py old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/reports/reports.xml b/odex25_accounting/account_budget_custom/reports/reports.xml old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/security/budget_groups.xml b/odex25_accounting/account_budget_custom/security/budget_groups.xml index 60f4c2128..80ba9d059 100644 --- a/odex25_accounting/account_budget_custom/security/budget_groups.xml +++ b/odex25_accounting/account_budget_custom/security/budget_groups.xml @@ -3,14 +3,14 @@ Budget User - + Budget Department Manager - + @@ -18,7 +18,7 @@ Budget Executive Director - + diff --git a/odex25_accounting/account_budget_custom/security/ir.model.access.csv b/odex25_accounting/account_budget_custom/security/ir.model.access.csv old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/static/description/icon.png b/odex25_accounting/account_budget_custom/static/description/icon.png old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/static/fonts/ae_AlMohanad.ttf b/odex25_accounting/account_budget_custom/static/fonts/ae_AlMohanad.ttf old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/static/src/css/website_rtl.css b/odex25_accounting/account_budget_custom/static/src/css/website_rtl.css old mode 100644 new mode 100755 diff --git a/odex25_accounting/account_budget_custom/views/account_budget_views.xml b/odex25_accounting/account_budget_custom/views/account_budget_views.xml old mode 100644 new mode 100755 index 285c6ffed..ad09f4343 --- a/odex25_accounting/account_budget_custom/views/account_budget_views.xml +++ b/odex25_accounting/account_budget_custom/views/account_budget_views.xml @@ -23,21 +23,41 @@ 1 + + show + + + show + + + show + + + show + + + show + + + show + - - - - - - - - + + + - - + + +