<commit_before>from odoo import models, fields, _, api


class SaleOrder(models.Model):
    _inherit = 'sale.order'

    def _compute_rma_count(self):
        for order in self:
            stage_sale_attach_id = self.env['crm.claim.stage'].search([('name', '=', 'Adjuntar con pedido')]).id
            pending_rmas = self.env['crm.claim'].search_count(
                [('partner_id', '=', order.partner_id.id), ('stage_id', '=', stage_sale_attach_id)])
            order.rma_pending_count = pending_rmas

    rma_pending_count = fields.Integer(compute='_compute_rma_count', default=0)

    def action_view_pending_rma(self):
        stage_sale_attach_id = self.env['crm.claim.stage'].search([('name', '=', 'Adjuntar con pedido')]).id
        pending_rmas = self.env['crm.claim'].search(
            [('partner_id', '=', self.partner_id.id), ('stage_id', '=', stage_sale_attach_id)])

        action = self.env.ref('crm_claim_rma_custom.action_show_pending_claims').read()[0]

        if len(pending_rmas) > 0:
            action['domain'] = [('id', 'in', pending_rmas.mapped('id'))]
        else:
            action = {'type': 'ir.actions.act_window_close'}
        return action


class SaleOrderClaimWizardLine(models.TransientModel):
    _name = 'sale.order.claim.wizard.line'

    choose = fields.Boolean('Add')
    claim_id = fields.Many2one('crm.claim', 'Claim')
    claim_id_ro = fields.Many2one('crm.claim', 'Claim', readonly=True)
    partner_id = fields.Many2one('res.partner', 'Partner', readonly=True)
    partner_shipping_id = fields.Many2one('res.partner', 'Shipping', readonly=True)
    wizard_id = fields.Many2one('sale.order.claim.wizard')


class SaleOrderClaimWizard(models.TransientModel):
    _name = 'sale.order.claim.wizard'

    @api.model
    def _get_pending_claims(self):
        wiz_lines = []
        order = self.env['sale.order'].browse(self.env.context.get('active_ids'))
        stage_sale_attach_id = self.env['crm.claim.stage'].search([('name', '=', 'Adjuntar con pedido')]).id
        pending_rmas = self.env['crm.claim'].search(
            [('partner_id', '=', order.partner_id.id), ('stage_id', '=', stage_sale_attach_id)])

        for rma in pending_rmas:
            new_line = {'choose': False,
                        'claim_id': rma.id,<commit_msg>[IMP]crm_claim_rma_custom: añadido filtro de envío<commit_after>from odoo import models, fields, _, api


class SaleOrder(models.Model):
    _inherit = 'sale.order'

    def _compute_rma_count(self):
        for order in self:
            stage_sale_attach_id = self.env['crm.claim.stage'].search([('name', '=', 'Adjuntar con pedido')]).id
            pending_rmas = self.env['crm.claim'].search_count(
                [('partner_id', '=', order.partner_id.id), ('stage_id', '=', stage_sale_attach_id),
                 ('delivery_address_id', '=', order.partner_shipping_id.id)])
            order.rma_pending_count = pending_rmas

    rma_pending_count = fields.Integer(compute='_compute_rma_count', default=0)

    def action_view_pending_rma(self):
        stage_sale_attach_id = self.env['crm.claim.stage'].search([('name', '=', 'Adjuntar con pedido')]).id
        pending_rmas = self.env['crm.claim'].search(
            [('partner_id', '=', self.partner_id.id), ('stage_id', '=', stage_sale_attach_id)])

        action = self.env.ref('crm_claim_rma_custom.action_show_pending_claims').read()[0]

        if len(pending_rmas) > 0:
            action['domain'] = [('id', 'in', pending_rmas.mapped('id'))]
        else:
            action = {'type': 'ir.actions.act_window_close'}
        return action


class SaleOrderClaimWizardLine(models.TransientModel):
    _name = 'sale.order.claim.wizard.line'

    choose = fields.Boolean('Add')
    claim_id = fields.Many2one('crm.claim', 'Claim')
    claim_id_ro = fields.Many2one('crm.claim', 'Claim', readonly=True)
    partner_id = fields.Many2one('res.partner', 'Partner', readonly=True)
    partner_shipping_id = fields.Many2one('res.partner', 'Shipping', readonly=True)
    wizard_id = fields.Many2one('sale.order.claim.wizard')


class SaleOrderClaimWizard(models.TransientModel):
    _name = 'sale.order.claim.wizard'

    @api.model
    def _get_pending_claims(self):
        wiz_lines = []
        order = self.env['sale.order'].browse(self.env.context.get('active_ids'))
        stage_sale_attach_id = self.env['crm.claim.stage'].search([('name', '=', 'Adjuntar con pedido')]).id
        pending_rmas = self.env['crm.claim'].search(
            [('partner_id', '=', order.partner_id.id), ('stage_id', '=', stage_sale_attach_id),
             ('delivery_address_id', '=', order.partner_shipping_id.id)])

        for rma in pending_rmas:
            new_line = {'choose': False,
                        'claim_id': rma.id,
{'fraction_non_alphanumeric': 0.16181703998325309, 'fraction_numerical': 0.0033493824576093785, 'mean_word_length': 3.4036866359447004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2272257', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1638, 'n_words': 233}