Files
encoach_backend_new_v2/odoo/addons/purchase/models/res_partner.py
Yamen Ahmad 3e83d8d7d5 feat: add complete EnCoach backend — Odoo 19 + all addons
Includes:
- Odoo 19 framework (odoo/)
- 27 custom EnCoach addons (new_project/custom_addons/)
  - encoach_core, encoach_api, encoach_lms_api, encoach_adaptive_api
  - encoach_exam, encoach_taxonomy, encoach_adaptive, encoach_assignment
  - encoach_ai, encoach_ai_grading, encoach_ai_generation, encoach_ai_media
  - encoach_courseware, encoach_communication, encoach_subscription
  - encoach_notification, encoach_approval, encoach_branding
  - encoach_classroom, encoach_registration, encoach_stats
  - encoach_faq, encoach_ticket, encoach_training, encoach_resources
  - encoach_adaptive_ai, encoach_sis
- 21 OpenEduCat Enterprise modules (new_project/enterprise-19/)
- 14 OpenEduCat Community modules (new_project/openeducat_erp-19.0/)
- Configuration: odoo.conf, requirements.txt, scripts
- 200+ REST API endpoints with JWT authentication
- SRS and test documentation

Made-with: Cursor
2026-04-01 17:10:04 +04:00

55 lines
2.5 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
def _compute_purchase_order_count(self):
self.purchase_order_count = 0
if not self.env.user._has_group('purchase.group_purchase_user'):
return
# retrieve all children partners and prefetch 'parent_id' on them
all_partners = self.with_context(active_test=False).search_fetch(
[('id', 'child_of', self.ids)],
['parent_id'],
)
purchase_order_groups = self.env['purchase.order']._read_group(
domain=[('partner_id', 'in', all_partners.ids)],
groupby=['partner_id'], aggregates=['__count'],
)
self_ids = set(self._ids)
for partner, count in purchase_order_groups:
while partner:
if partner.id in self_ids:
partner.purchase_order_count += count
partner = partner.parent_id
property_purchase_currency_id = fields.Many2one(
'res.currency', string="Supplier Currency", company_dependent=True,
help="This currency will be used for purchases from the current partner")
purchase_order_count = fields.Integer(
string="Purchase Order Count",
groups='purchase.group_purchase_user',
compute='_compute_purchase_order_count',
)
purchase_warn_msg = fields.Text('Message for Purchase Order')
receipt_reminder_email = fields.Boolean('Receipt Reminder', company_dependent=True,
help="Automatically send a confirmation email to the vendor X days before the expected receipt date, asking him to confirm the exact date.")
reminder_date_before_receipt = fields.Integer('Days Before Receipt', company_dependent=True,
help="Number of days to send reminder email before the promised receipt date")
buyer_id = fields.Many2one('res.users', string='Buyer')
def _compute_application_statistics_hook(self):
data_list = super()._compute_application_statistics_hook()
if not self.env.user.has_group('purchase.group_purchase_user'):
return data_list
for partner in self.filtered(lambda partner: partner.purchase_order_count):
stat_info = {'iconClass': 'fa-credit-card', 'value': partner.purchase_order_count, 'label': _('Purchases'), 'tagClass': 'o_tag_color_5'}
data_list[partner.id].append(stat_info)
return data_list