Skip to content

Commit

Permalink
fixup! fixup! [ADD] stock_picking_auto_print
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaudoux committed Dec 16, 2022
1 parent fdb2477 commit c14ee68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions printing_auto_base/models/printing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def check_report(self):
if rec.file_type == "report" and not rec.report_id:
raise UserError(_("Report was not set"))

def do_print(self, pickings):
def do_print(self, picking):
self.ensure_one()
picking.ensure_one()

behaviour = self.get_behaviour()
printer = behaviour["printer"]
Expand All @@ -65,16 +66,15 @@ def do_print(self, pickings):

if self.nbr_of_copies <= 0:
return (printer, 0)
if not self._check_condition(picking):
return (printer, 0)

count = 0
for picking in pickings:
if not self._check_condition(picking):
continue
record = self._get_record(picking)
for content in self.get_content(record):
for _n in range(self.nbr_of_copies):
printer.print_document(report=None, content=content, **behaviour)
count += 1
record = self._get_record(picking)
for content in self.get_content(record):
for _n in range(self.nbr_of_copies):
printer.print_document(report=None, content=content, **behaviour)
count += 1
return (printer, count)

def get_behaviour(self):
Expand Down
4 changes: 2 additions & 2 deletions printing_auto_stock_picking/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def send_documents_to_printer(self):
if count:
self.message_post(
body=_(
"Report {name} sent to printer {printer}"
).format(name=auto, printer=printer)
"{name}: {count} document(s) sent to printer {printer}"
).format(name=auto, count=count, printer=printer)
)
except Exception:
_logger.exception(
Expand Down
4 changes: 2 additions & 2 deletions printing_auto_stock_picking/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_manager,stock_picking_auto_print - manager,model_stock_auto_printing,stock.group_stock_manager,1,1,1,1
access_user,stock_picking_auto_print - user,model_stock_auto_printing,stock.group_stock_user,1,0,0,0
access_manager,stock_picking_auto_print - manager,model_printing_auto,stock.group_stock_manager,1,1,1,1
access_user,stock_picking_auto_print - user,model_printing_auto,stock.group_stock_user,1,0,0,0

0 comments on commit c14ee68

Please sign in to comment.