Print report for selected partner only

There is a Partner Directory report, but it only prints for all partners. so i added partner id in wizard and wizard view. Now I need a method that will only print the report for selected partners. Hope you guys can give me some food for thought. maybe some pseudo code how should i implement it.

class AccountPartnerLedger(models.TransientModel):
    _inherit = "account.report.partner.ledger"

    partner_ids = fields.Many2many(
        'res.partner', string='Choose partners')

      

I am trying to filter with a domain method that calls the report

class ReportPartnerLedger(models.AbstractModel):
    _inherit = 'report.account_extra_reports.report_partnerledger'


    @api.multi
    def render_html(self, data):
        domain = [
                ('partner_ids', '==', 'partner_ids'),
            ]
        return super(ReportPartnerLedger, self).render_html(data=data)

      

+3


source to share


1 answer


In general, if you want to filter in a partner ledger, you need to override one method from which all partners are installed.

For this you can link

account => report => report_partner_ledger.py

There is one method in this file

def set_context(self, objects, data, ids, report_type=None):

      



You need to override it and you need to update one line that will display all partners instead, you need to pass the field value here.

    self.cr.execute(
            "SELECT DISTINCT l.partner_id " \
            "FROM account_move_line AS l, account_account AS account, " \
            " account_move AS am " \
            "WHERE l.partner_id IS NOT NULL " \
                "AND l.account_id = account.id " \
                "AND am.id = l.move_id " \
                "AND am.state IN %s"
                "AND " + self.query +" " \
                "AND l.account_id IN %s " \
                " " + PARTNER_REQUEST + " " \
                "AND account.active " + reconcile + " ", params)
    self.partner_ids = [res['partner_id'] for res in self.cr.dictfetchall()]

      

This way odoo picks up all partners for the lead partner report, so just comment these lines and replace your code.

To do this, you need to inherit from the master, because in this partner_ids, where you need to replace this value.

0


source







All Articles