mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-26 12:12:05 +02:00
Initial commit: Sale packages
This commit is contained in:
commit
14e3d26998
6469 changed files with 2479670 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
crm_team_ids = fields.Many2many(
|
||||
'crm.team', 'crm_team_member', 'user_id', 'crm_team_id', string='Sales Teams',
|
||||
check_company=True, copy=False, readonly=True,
|
||||
compute='_compute_crm_team_ids', search='_search_crm_team_ids')
|
||||
crm_team_member_ids = fields.One2many('crm.team.member', 'user_id', string='Sales Team Members')
|
||||
sale_team_id = fields.Many2one(
|
||||
'crm.team', string='User Sales Team', compute='_compute_sale_team_id',
|
||||
readonly=True, store=True,
|
||||
help="Main user sales team. Used notably for pipeline, or to set sales team in invoicing or subscription.")
|
||||
|
||||
@api.depends('crm_team_member_ids.active')
|
||||
def _compute_crm_team_ids(self):
|
||||
for user in self:
|
||||
user.crm_team_ids = user.crm_team_member_ids.crm_team_id
|
||||
|
||||
def _search_crm_team_ids(self, operator, value):
|
||||
return [('crm_team_member_ids.crm_team_id', operator, value)]
|
||||
|
||||
@api.depends('crm_team_member_ids.crm_team_id', 'crm_team_member_ids.create_date', 'crm_team_member_ids.active')
|
||||
def _compute_sale_team_id(self):
|
||||
for user in self:
|
||||
if not user.crm_team_member_ids.ids:
|
||||
user.sale_team_id = False
|
||||
else:
|
||||
sorted_memberships = user.crm_team_member_ids # sorted by create date
|
||||
user.sale_team_id = sorted_memberships[0].crm_team_id if sorted_memberships else False
|
||||
Loading…
Add table
Add a link
Reference in a new issue