mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] add test to check sales channel domain
This commit is contained in:
committed by
Darío Lodeiros
parent
d5de68e120
commit
29fc701c52
@@ -21,6 +21,12 @@ class ResPartner(models.Model):
|
||||
folios_count = fields.Integer("Folios", compute="_compute_folios_count")
|
||||
unconfirmed = fields.Boolean("Unconfirmed", default=True)
|
||||
is_agency = fields.Boolean("Is Agency")
|
||||
sale_channel_id = fields.Many2one(
|
||||
"pms.sale.channel",
|
||||
string="Sale Channel",
|
||||
ondelete = "restrict",
|
||||
domain=[("channel_type","=","indirect")],
|
||||
)
|
||||
|
||||
# Compute and Search methods
|
||||
def _compute_reservations_count(self):
|
||||
@@ -64,3 +70,11 @@ class ResPartner(models.Model):
|
||||
name, args=args, operator=operator, limit=limit_rest
|
||||
)
|
||||
return res
|
||||
|
||||
@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"))
|
||||
if not record.is_agency and record.sale_channel_id:
|
||||
record.sale_channel_id=None
|
||||
|
||||
Reference in New Issue
Block a user