odoo10_addons

Check-in [731a3190f8]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:trial_balance_co: adiciona atributo account_code_prev_balance_ignore, como entra de texto donde espera separador por coma, a las cuentas cuyo codigo se omite balance previo
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | enterprise
Files: files | file ages | folders
SHA3-256: 731a3190f8e6c9e2656b6cf0a94b841f3b5ca1d83b6a0ecea3924a488c8d700c
User & Date: bit4bit 2019-04-02 15:16:07
Context
2019-04-02
15:20
trial_balance_co: localizacion Leaf check-in: b54506d4dc user: bit4bit tags: enterprise
15:16
trial_balance_co: adiciona atributo account_code_prev_balance_ignore, como entra de texto donde espera separador por coma, a las cuentas cuyo codigo se omite balance previo check-in: 731a3190f8 user: bit4bit tags: enterprise
2019-03-14
20:42
trial_balance_co: se adiciona sumatorio en balance_total check-in: 9ae465ef78 user: bit4bit tags: enterprise
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to trial_balance_co/report/balance.py.

96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
...
129
130
131
132
133
134
135








136
137
138
139
140
141
142
143
...
250
251
252
253
254
255
256






257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
            account_result[rid].append(row)
            assert key not in indexes or (key in indexes and indexes[key] == 0 )
            indexes[key] = len(account_result[rid]) - 1
        
        return (account_result, indexes)


    def _get_accounts_by_code(self, used_context, accounts, display_account, default_account_id):

        results = self._fetch_moves_by_account_code(accounts, default_account_id)
        date_to = dateutil.parser.parse(used_context['date_from']) - timedelta(days=1)
        used_context_previous = copy.copy(used_context)
        used_context_previous.update({'date_to': date_to, 'date_from': False})
        account_result_previous = self.with_context(used_context_previous)._fetch_moves_by_account_code(accounts, default_account_id)

        res = []
................................................................................
            }
            result['type'] = 'line'
            result.update(results.get(code, {}))
            result['balance_prev'] = 0.0
            result['balance_total'] = 0.0

            if code in account_result_previous:








                result['balance_prev'] = account_result_previous[code]['balance']
                result['code'] = account_result_previous[code]['code']
                result['name'] = account_result_previous[code]['name']

            result['balance_total'] = result.get('balance_prev', 0.0) + result.get('balance', 0.0)
            res.append(result)

        return res
................................................................................
            raise UserError(_("Form content is missing, this report cannot be printed."))

        self.model = self.env.context.get('active_model')
        docs = self.env[self.model].browse(self.env.context.get('active_ids', []))
        display_account = data['form'].get('display_account')
        default_partner = data['form'].get('default_unknown_partner_id')
        default_account = data['form'].get('default_unknown_account_id')






        group_by = data['form'].get('group_by')
        accounts = docs if self.model == 'account.account' else self.env['account.account'].search([])
        if group_by == 'partner':
            account_res = self.with_context(data['form'].get('used_context'))\
                              ._get_accounts(data['form'].get('used_context'), accounts, display_account, default_partner)
        elif group_by == 'code':
            account_res = self.with_context(data['form'].get('used_context'))\
                              ._get_accounts_by_code(data['form'].get('used_context'), accounts, display_account, default_account)
        else:
            raise RuntimeError('unknown group_by %s' %(group_by))

        docargs = {
            'doc_ids': self.ids,
            'doc_model': self.model,
            'data': data['form'],
            'docs': docs,
            'time': time,
            'Accounts': account_res,
        }

        return self.env['report'].render('trial_balance_co.report_partner_trial_balance', docargs)







|
>







 







>
>
>
>
>
>
>
>
|







 







>
>
>
>
>
>







|













96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
            account_result[rid].append(row)
            assert key not in indexes or (key in indexes and indexes[key] == 0 )
            indexes[key] = len(account_result[rid]) - 1
        
        return (account_result, indexes)


    def _get_accounts_by_code(self, used_context, accounts, display_account,
                              default_account_id, account_code_prev_balance_ignore):
        results = self._fetch_moves_by_account_code(accounts, default_account_id)
        date_to = dateutil.parser.parse(used_context['date_from']) - timedelta(days=1)
        used_context_previous = copy.copy(used_context)
        used_context_previous.update({'date_to': date_to, 'date_from': False})
        account_result_previous = self.with_context(used_context_previous)._fetch_moves_by_account_code(accounts, default_account_id)

        res = []
................................................................................
            }
            result['type'] = 'line'
            result.update(results.get(code, {}))
            result['balance_prev'] = 0.0
            result['balance_total'] = 0.0

            if code in account_result_previous:
                ignore_balance_prev = False
                for code_ignore in account_code_prev_balance_ignore:
                    if code.startswith(code_ignore):
                        ignore_balance_prev = True
                        break

                result['balance_prev'] = 0.0
                if not ignore_balance_prev:
                    result['balance_prev'] = account_result_previous[code]['balance']
                result['code'] = account_result_previous[code]['code']
                result['name'] = account_result_previous[code]['name']

            result['balance_total'] = result.get('balance_prev', 0.0) + result.get('balance', 0.0)
            res.append(result)

        return res
................................................................................
            raise UserError(_("Form content is missing, this report cannot be printed."))

        self.model = self.env.context.get('active_model')
        docs = self.env[self.model].browse(self.env.context.get('active_ids', []))
        display_account = data['form'].get('display_account')
        default_partner = data['form'].get('default_unknown_partner_id')
        default_account = data['form'].get('default_unknown_account_id')
        account_code_prev_balance_ignore = data['form'].get('account_code_prev_balance_ignore')
        if account_code_prev_balance_ignore:
            account_code_prev_balance_ignore = account_code_prev_balance_ignore.split(",")
        else:
            account_code_prev_balance_ignore = []
            
        group_by = data['form'].get('group_by')
        accounts = docs if self.model == 'account.account' else self.env['account.account'].search([])
        if group_by == 'partner':
            account_res = self.with_context(data['form'].get('used_context'))\
                              ._get_accounts(data['form'].get('used_context'), accounts, display_account, default_partner)
        elif group_by == 'code':
            account_res = self.with_context(data['form'].get('used_context'))\
                              ._get_accounts_by_code(data['form'].get('used_context'), accounts, display_account, default_account, account_code_prev_balance_ignore)
        else:
            raise RuntimeError('unknown group_by %s' %(group_by))

        docargs = {
            'doc_ids': self.ids,
            'doc_model': self.model,
            'data': data['form'],
            'docs': docs,
            'time': time,
            'Accounts': account_res,
        }

        return self.env['report'].render('trial_balance_co.report_partner_trial_balance', docargs)

Changes to trial_balance_co/wizard/report_partner_trial_balance.py.

8
9
10
11
12
13
14

15
16
17
18
19
20
21
22
23
24
25

26
27
28
29
30
31
32

    date_from = fields.Date(string='Start Date', required=True)
    #TODO se sobreescribe relacion
    #por tamano en base de datos
    journal_ids = fields.Many2many('account.journal', 'trial_balance_co_reportptr_journal_rel', 'account_id', 'journal_id', string='Journals', required=True)
    default_unknown_partner = fields.Many2one('res.partner', string='Default Unknown Partner', required=True)
    default_unknown_account = fields.Many2one('account.account', string='Default Unknown Account', required=True)

    
    group_by = fields.Selection([
        ('partner', 'Partner'),
        ('code', 'Account Code')
    ], string='Group By', required=True)

    def _print_report(self, data):
        data = self.pre_print_report(data)
        data['form'].update({
            'default_unknown_partner_id': self.default_unknown_partner.id,
            'default_unknown_account_id': self.default_unknown_account.id,

            'group_by': self.group_by
        })
        records = self.env[data['model']].browse(data.get('ids', []))
        action = self.env['report'].get_action(records, 'trial_balance_co.report_partner_trial_balance', data=data)
        return action









>











>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

    date_from = fields.Date(string='Start Date', required=True)
    #TODO se sobreescribe relacion
    #por tamano en base de datos
    journal_ids = fields.Many2many('account.journal', 'trial_balance_co_reportptr_journal_rel', 'account_id', 'journal_id', string='Journals', required=True)
    default_unknown_partner = fields.Many2one('res.partner', string='Default Unknown Partner', required=True)
    default_unknown_account = fields.Many2one('account.account', string='Default Unknown Account', required=True)
    account_code_prev_balance_ignore = fields.Char('Account Code Prev. Balance Ignore', help='Codes separate by comma,')
    
    group_by = fields.Selection([
        ('partner', 'Partner'),
        ('code', 'Account Code')
    ], string='Group By', required=True)

    def _print_report(self, data):
        data = self.pre_print_report(data)
        data['form'].update({
            'default_unknown_partner_id': self.default_unknown_partner.id,
            'default_unknown_account_id': self.default_unknown_account.id,
            'account_code_prev_balance_ignore': self.account_code_prev_balance_ignore,
            'group_by': self.group_by
        })
        records = self.env[data['model']].browse(data.get('ids', []))
        action = self.env['report'].get_action(records, 'trial_balance_co.report_partner_trial_balance', data=data)
        return action


Changes to trial_balance_co/wizard/report_partner_trial_balance_view.xml.

8
9
10
11
12
13
14

15
16
17
18
19
20
21
        <field name="inherit_id" ref="account.account_common_report_view"/>
        <field name="arch" type="xml">
          <data>
            <xpath expr="//field[@name='target_move']" position="after">
              <field name="display_account" widget="radio"/>
              <field name="default_unknown_partner" />
              <field name="default_unknown_account" />

              <field name="group_by" />
              <newline/>
            </xpath>
          </data>
        </field>
    </record>








>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
        <field name="inherit_id" ref="account.account_common_report_view"/>
        <field name="arch" type="xml">
          <data>
            <xpath expr="//field[@name='target_move']" position="after">
              <field name="display_account" widget="radio"/>
              <field name="default_unknown_partner" />
              <field name="default_unknown_account" />
              <field name="account_code_prev_balance_ignore"/>
              <field name="group_by" />
              <newline/>
            </xpath>
          </data>
        </field>
    </record>