Skip to content

Commit

Permalink
[IMP] pos_disable_pricelist_selection: selectable pricelists
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasProgrammer committed Dec 15, 2023
1 parent 9407ed7 commit 689f974
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pos_disable_pricelist_selection/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
class PosConfig(models.Model):
_inherit = "pos.config"

def _default_pricelist(self):
return self.env["product.pricelist"].search(
[
("company_id", "in", (False, self.env.company.id)),
("currency_id", "=", self.env.company.currency_id.id),
],
limit=1,
)

hide_pricelist_button = fields.Boolean(
default=False,
)
Expand All @@ -12,14 +21,15 @@ class PosConfig(models.Model):
string="Selectable Pricelists",
domain="[('id', 'in', available_pricelist_ids)]",
relation="pos_conf_selectable_pricelist_rel",
default=_default_pricelist,
)
pricelist_id_domain = fields.Binary(
compute="_compute_pricelist_id_domain",
readonly=True,
store=False,
)

@api.depends("hide_pricelist_button")
@api.onchange("hide_pricelist_button")
def onchange_hide_pricelist_button(self):
self.update(
{"selectable_pricelist_ids": [(6, 0, self.allowed_pricelist_ids.ids)]}
Expand All @@ -34,7 +44,9 @@ def _compute_pricelist_id_domain(self):
rec.pricelist_id_domain = [("id", "in", rec.allowed_pricelist_ids.ids)]
else:
if not rec.selectable_pricelist_ids:
rec.selectable_pricelist_ids = [(6, 0, rec.allowed_pricelist_ids.ids)]
rec.selectable_pricelist_ids = [
(6, 0, rec.allowed_pricelist_ids.ids)
]
rec.pricelist_id_domain = [
("id", "in", rec.selectable_pricelist_ids.ids)
]

0 comments on commit 689f974

Please sign in to comment.