(self)
return True
creates partner records in 349
creates partner records in 349
creates partner records in 349
def _create_349_invoice_records(self):
        """creates partner records in 349"""
        rec_obj = self.env["l10n.es.aeat.mod349.partner_record"]
        detail_obj = self.env["l10n.es.aeat.mod349.partner_record_detail"]
        data = {}
        for record_detail in self.partner_record_detail_ids:
            move_line = record_detail.move_line_id
            partner = move_line.partner_id
            op_key = move_line.l10n_es_aeat_349_operation_key
            partner_dict = data.setdefault(partner, {})
            op_key_dict = partner_dict.setdefault(
                op_key,
                {"record_details": detail_obj},
            )
            op_key_dict["record_details"] += record_detail
        for partner in list(data.keys()):
            for op_key in list(data[partner].keys()):
                record_created = rec_obj.create(
                    {
                        "report_id": self.id,
                        "partner_id": partner.id,
                        "partner_vat": partner.vat,
                        "operation_key": op_key,
                        "country_id": partner.country_id.id,
                    }
                )
                for record_detail in data[partner][op_key]["record_details"]:
                    record_detail.partner_record_id = record_created
        rounding = self.env.user.company_id.currency_id.rounding
        self.partner_record_ids.filtered(
            lambda r: float_is_zero(
                r.total_operation_amount, precision_rounding=rounding
            )
        ).unlink()
        return True
def _create_349_invoice_records ( self ) : rec_obj = self . env [ "l10n.es.aeat.mod349.partner_record" ] detail_obj = self . env [ "l10n.es.aeat.mod349.partner_record_detail" ] data = { } for record_detail in self . partner_record_detail_ids : move_line = record_detail . move_line_id partner = move_line . partner_id op_key = move_line . l10n_es_aeat_349_operation_key partner_dict = data . setdefault ( partner , { } ) op_key_dict = partner_dict . setdefault ( op_key , { "record_details" : detail_obj } , ) op_key_dict [ "record_details" ] += record_detail for partner in list ( data . keys ( ) ) : for op_key in list ( data [ partner ] . keys ( ) ) : record_created = rec_obj . create ( { "report_id" : self . id , "partner_id" : partner . id , "partner_vat" : partner . vat , "operation_key" : op_key , "country_id" : partner . country_id . id , } ) for record_detail in data [ partner ] [ op_key ] [ "record_details" ] : record_detail . partner_record_id = record_created rounding = self . env . user . company_id . currency_id . rounding self . partner_record_ids . filtered ( lambda r : float_is_zero ( r . total_operation_amount , precision_rounding = rounding ) ) . unlink ( ) return True