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 c7cad4d commit 384064b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pos_disable_pricelist_selection/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ def _default_pricelist(self):
store=False,
)

@api.depends("available_pricelist_ids")
def _compute_selectable_pricelist_ids(self):
for rec in self:
rec.selectable_pricelist_ids = [(6, 0, rec.allowed_pricelist_ids.ids)]

@api.depends(
"hide_pricelist_button", "allowed_pricelist_ids", "selectable_pricelist_ids"
)
Expand Down Expand Up @@ -65,5 +60,14 @@ def onchange_hide_pricelist_button(self):

def write(self, vals):
if vals.get("available_pricelist_ids"):
vals["selectable_pricelist_ids"] = vals["available_pricelist_ids"]
if self:
# leave only ids from available_pricelist_ids
diff = list(
set(self.selectable_pricelist_ids.ids).intersection(
set(vals["available_pricelist_ids"][0][2])
)
)
vals["selectable_pricelist_ids"] = [(6, 0, diff)]
else:
vals["selectable_pricelist_ids"] = vals["available_pricelist_ids"]
return super(PosConfig, self).write(vals)

0 comments on commit 384064b

Please sign in to comment.