mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-23 22:52:02 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,42 @@
|
|||
# Copyright 2015 Antiun Ingenieria - Endika Iglesias <endikaig@antiun.com>
|
||||
# Copyright 2017 Tecnativa - Luis Martínez
|
||||
# Copyright 2019 Tecnativa - Alexandre Díaz
|
||||
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class CrmLead(models.Model):
|
||||
_inherit = "crm.lead"
|
||||
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="res.city.zip",
|
||||
string="Location",
|
||||
index="btree",
|
||||
help="Use the city name or the zip code to search the location",
|
||||
compute="_compute_location_id",
|
||||
readonly=False,
|
||||
store=True,
|
||||
)
|
||||
|
||||
@api.depends("location_id")
|
||||
def _compute_partner_address_values(self):
|
||||
res = super()._compute_partner_address_values()
|
||||
for lead in self.filtered("location_id"):
|
||||
lead.update(
|
||||
{
|
||||
"zip": lead.location_id.name,
|
||||
"city": lead.location_id.city_id.name,
|
||||
"state_id": lead.location_id.city_id.state_id,
|
||||
"country_id": lead.location_id.city_id.country_id,
|
||||
}
|
||||
)
|
||||
return res
|
||||
|
||||
@api.depends("partner_id")
|
||||
def _compute_location_id(self):
|
||||
for lead in self:
|
||||
if lead.partner_id.zip_id:
|
||||
lead.location_id = lead.partner_id.zip_id.id
|
||||
elif lead.location_id:
|
||||
lead.location_id = lead.location_id.id
|
||||
Loading…
Add table
Add a link
Reference in a new issue