[IMP] precommit fixed

This commit is contained in:
Sara Lago
2020-11-17 09:21:02 +01:00
committed by Darío Lodeiros
parent 29fc701c52
commit 121bd7c260
8 changed files with 78 additions and 102 deletions

View File

@@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from odoo import api, fields, models
from odoo import _, api, fields, models
_logger = logging.getLogger(__name__)
@@ -24,8 +24,8 @@ class ResPartner(models.Model):
sale_channel_id = fields.Many2one(
"pms.sale.channel",
string="Sale Channel",
ondelete = "restrict",
domain=[("channel_type","=","indirect")],
ondelete="restrict",
domain=[("channel_type", "=", "indirect")],
)
# Compute and Search methods
@@ -71,10 +71,10 @@ class ResPartner(models.Model):
)
return res
@api.constrains("is_agency","sale_channel_id")
@api.constrains("is_agency", "sale_channel_id")
def _check_is_agency(self):
for record in self:
if record.is_agency and not record.sale_channel_id:
raise models.ValidationError(_("Sale Channel must be entered"))
raise models.ValidationError(_("Sale Channel must be entered"))
if not record.is_agency and record.sale_channel_id:
record.sale_channel_id=None
record.sale_channel_id = None