Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing multiple items directly to a printer only prints first item #62

Open
a0c opened this issue Sep 27, 2015 · 3 comments
Open

Printing multiple items directly to a printer only prints first item #62

a0c opened this issue Sep 27, 2015 · 3 comments

Comments

@a0c
Copy link
Contributor

a0c commented Sep 27, 2015

  1. Configure user's default general purpose printer to be e.g. PDF (sudo apt-get install cups-pdf + update Direct printing configuration in Odoo).

  2. Pick some Aeroo report (AR) with client_print_multi set, and set User's Default Genreral Purpose Printer as this report's Printer.

  3. Finally, select several items and go Print > AR. Out of all selected items only the 1st item is printed to a PDF file.

a0c added a commit to a0c/aeroo_reports that referenced this issue Sep 27, 2015
a0c added a commit to a0c/aeroo_reports that referenced this issue Sep 27, 2015
@sraps
Copy link
Contributor

sraps commented Sep 29, 2015

Although I have not tested the problem, still I do not agree on the solution... Either it is not necessary, or it is useless.
Following two lines are just takes the ids from a key in context and then places it back:

ids = context.get('active_ids', ids)
context['active_ids'] = ids

@a0c
Copy link
Contributor Author

a0c commented Sep 29, 2015

I wouldn't call this solution elegant either, but it works.
Following two lines are just takes the ids from a key in context and then places it back:
No, they don't. That's exactly the problem: ids and active_ids do not match in case of multiple item printing. They only match if you print a single object. If however you select several objects, your active_ids would be e.g. [4,5,6,7], the ids will though be just [4].

ids come from this line in report_aeroo_direct_print.py -- namely [obj.id]:

                python_code = """
# %s #
report_action_id = %s
context['report_action_id'] = report_action_id
print_actions_obj = self.pool.get('aeroo.print_actions')
printer = print_actions_obj._get_default_printer(cr, uid, context)
print_actions_obj.report_to_printer(cr, uid, [obj.id], report_action_id, printer, context=context)
""" % (md5.md5(str(report_id)).hexdigest(), report_id)

In turn, obj comes from a server action created by _set_report_server_action() method. Namely, obj is set as a singleton in the eval_context of the run() method of server action. And the generated code of direct_print is executed from line 1002, not from 1016 during iteration of active_ids. Hence only the first record gets printed, as it succeeds in making it into the obj inside of eval_context.

So, to fix the issue w/o touching odoo base code, we either change the generated python_code to make it pick the right ids from context['active_ids'], or do it the way I proposed. Of course, both solutions don't look elegant. But at least now you know the logic behind it.

And of course I would be more than happy if somebody would come with a better one.

@sraps
Copy link
Contributor

sraps commented Sep 29, 2015

Thank you. I meant that, 'ids' would never be taken unless there is no key 'active_ids' at all. Even the 'active_ids' key is None or empty list, or anything else "type-casted" to boolean False, the value of the key would be taken, even there is something valuable in 'ids'.

aaltinisik added a commit to aaltinisik/aeroo_reports that referenced this issue Dec 12, 2015
[FIX] aeroo#62: Printing multiple items directly to a printer only prints …
a0c added a commit to a0c/aeroo_reports that referenced this issue Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants