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 baa45bb commit 80bcc82
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pos_disable_pricelist_selection/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ 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])
)
)
if diff:
vals["selectable_pricelist_ids"] = [(6, 0, diff)]
if self and not vals.get("selectable_pricelist_ids"):
selectable = set(self.selectable_pricelist_ids.ids)
else:
selectable = set(vals["selectable_pricelist_ids"][0][2])
# leave only ids from available_pricelist_ids
diff = list(
selectable.intersection(set(vals["available_pricelist_ids"][0][2]))
)
if diff:
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 80bcc82

Please sign in to comment.