mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 19:12:06 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,10 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.osv import expression
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.fields import Domain
|
||||
|
||||
|
||||
class CrmLead(models.Model):
|
||||
|
|
@ -46,8 +43,8 @@ class CrmLead(models.Model):
|
|||
action = self.env["ir.actions.actions"]._for_xml_id("sale.action_quotations_with_onboarding")
|
||||
action['context'] = self._prepare_opportunity_quotation_context()
|
||||
action['context']['search_default_draft'] = 1
|
||||
action['domain'] = expression.AND([[('opportunity_id', '=', self.id)], self._get_lead_quotation_domain()])
|
||||
quotations = self.order_ids.filtered_domain(self._get_lead_quotation_domain())
|
||||
action['domain'] = Domain.AND([[('opportunity_id', '=', self.id)], self._get_action_view_sale_quotation_domain()])
|
||||
quotations = self.order_ids.filtered_domain(self._get_action_view_sale_quotation_domain())
|
||||
if len(quotations) == 1:
|
||||
action['views'] = [(self.env.ref('sale.view_order_form').id, 'form')]
|
||||
action['res_id'] = quotations.id
|
||||
|
|
@ -61,13 +58,16 @@ class CrmLead(models.Model):
|
|||
'default_partner_id': self.partner_id.id,
|
||||
'default_opportunity_id': self.id,
|
||||
}
|
||||
action['domain'] = expression.AND([[('opportunity_id', '=', self.id)], self._get_lead_sale_order_domain()])
|
||||
action['domain'] = Domain.AND([[('opportunity_id', '=', self.id)], self._get_lead_sale_order_domain()])
|
||||
orders = self.order_ids.filtered_domain(self._get_lead_sale_order_domain())
|
||||
if len(orders) == 1:
|
||||
action['views'] = [(self.env.ref('sale.view_order_form').id, 'form')]
|
||||
action['res_id'] = orders.id
|
||||
return action
|
||||
|
||||
def _get_action_view_sale_quotation_domain(self):
|
||||
return [('state', 'in', ('draft', 'sent', 'cancel'))]
|
||||
|
||||
def _get_lead_quotation_domain(self):
|
||||
return [('state', 'in', ('draft', 'sent'))]
|
||||
|
||||
|
|
@ -98,3 +98,12 @@ class CrmLead(models.Model):
|
|||
# add all the orders from all lead to merge
|
||||
fields_info['order_ids'] = lambda fname, leads: [(4, order.id) for order in leads.order_ids]
|
||||
return fields_info
|
||||
|
||||
def _update_revenues_from_so(self, order):
|
||||
for opportunity in self:
|
||||
if (
|
||||
(opportunity.expected_revenue or 0) < order.amount_untaxed
|
||||
and order.currency_id == opportunity.company_id.currency_id
|
||||
):
|
||||
opportunity.expected_revenue = order.amount_untaxed
|
||||
opportunity._track_set_log_message(_('Expected revenue has been updated based on the linked Sales Orders.'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue