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

Master add new individual account report sed #30487

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
4 participants
@tivisse
Copy link
Contributor

tivisse commented Jan 23, 2019

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo robodoo added the seen 🙂 label Jan 23, 2019

@tivisse tivisse changed the base branch from 12.0 to master Jan 23, 2019

addons/l10n_be_hr_payroll/report/hr_individual_account_reports.py Outdated
payslip_rules += self.env.ref("hr_payroll.structure_base").get_all_rules()
payslip_rules = sorted(payslip_rules, key=lambda x: x[1])

data_read = self.env['hr.payslip.line'].read_group([('employee_id.id', 'in', data['emp'])], ['employee_id', 'ids:array_agg(id)'], ['employee_id', "date_from:%s" % ('month')], lazy=False)

This comment has been minimized.

@tivisse

tivisse Jan 23, 2019

Author Contributor

Use only one search.

Iterate on all the payslip lines, populate the dictionary {key(employee): value(dictionary)} as discussed together.

This comment has been minimized.

@tivisse

tivisse Jan 23, 2019

Author Contributor

Use dict.fromkeys to initialize the dictionary, and do something like :

result = dict.fromkeys(employees, dict.fromkeys(rules, {'year': 0, 'month': [0]*12, 'quarter': [0]*4}))
for line in lines:
    result[employee][rule]['month'][3] += value

@C3POdoo C3POdoo added the RD label Jan 23, 2019

@robodoo robodoo added the CI 🤖 label Jan 25, 2019

@sed-odoo sed-odoo force-pushed the odoo-dev:master-add-new-individual-account-report-sed branch Jan 28, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jan 28, 2019

@sed-odoo sed-odoo force-pushed the odoo-dev:master-add-new-individual-account-report-sed branch Feb 7, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Feb 7, 2019

@sed-odoo sed-odoo force-pushed the odoo-dev:master-add-new-individual-account-report-sed branch Feb 8, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Feb 8, 2019

@tivisse
Copy link
Contributor Author

tivisse left a comment

First review, small changes, otherwise it looks good and simpler to read ;)

Thanks.

@@ -25,7 +25,11 @@
'views/reports.xml',
'views/l10n_be_hr_payroll_view.xml',
'data/l10n_be_hr_payroll_data.xml',
'data/report_paperformat.xml',

This comment has been minimized.

@tivisse

tivisse Feb 18, 2019

Author Contributor

Rename into report_paperformat_data.xml, guidelines ;)

addons/l10n_be_hr_payroll/report/hr_individual_account_reports.py Outdated
_name = 'report.l10n_be_hr_payroll.report_individual_account'
_description = 'Individual Account Report'

def _month_to_number(self, month):

This comment has been minimized.

@tivisse

tivisse Feb 18, 2019

Author Contributor

Seems unused, to remove.

addons/l10n_be_hr_payroll/wizard/hr_individual_account_employees.py Outdated

year = fields.Selection([[str(i), i] for i in range(1990, datetime.datetime.now().year + 1)], string='Year', required=True,
default=lambda *a: str(datetime.datetime.now().year))
emp = fields.Many2many('hr.employee', string='Employee(s)')

This comment has been minimized.

@tivisse

tivisse Feb 18, 2019

Author Contributor

Rename into employee_ids

addons/l10n_be_hr_payroll/wizard/hr_individual_account_employees.py Outdated
def print_report(self):
self.ensure_one()
[data] = self.read()
data['emp'] = self.env.context.get('active_ids', [])

This comment has been minimized.

@tivisse

tivisse Feb 18, 2019

Author Contributor

data['employee_ids']

addons/l10n_be_hr_payroll/wizard/hr_individual_account_employees.py Outdated
data['year'] = int(self.year)
employees = self.env['hr.employee'].browse(data['emp'])
datas = {
'ids': [],

This comment has been minimized.

@tivisse

tivisse Feb 18, 2019

Author Contributor

Seems to be unused, could be removed.

addons/l10n_be_hr_payroll/wizard/hr_individual_account_employees.py Outdated
'model': 'hr.employee',
'form': data
}
return self.env.ref('l10n_be_hr_payroll.action_report_individual_account').report_action(employees, data=datas)

This comment has been minimized.

@tivisse

tivisse Feb 18, 2019

Author Contributor

If you look at the method report_action
It's not mandatory to provide a browse record. In fact we even do doc_ids.ids if it's the case.

        if docids:
            if isinstance(docids, models.Model):
                active_ids = docids.ids
            elif isinstance(docids, int):
                active_ids = [docids]
            elif isinstance(docids, list):
                active_ids = docids

So you could avoid to browse the employees and pass the ids directly.

addons/l10n_be_hr_payroll/report/hr_individual_account_reports.py Outdated
'December': 12})
return month_dict[month.split()[0]]

def _get_data_from_report(self, data):

This comment has been minimized.

@tivisse

tivisse Feb 18, 2019

Author Contributor

Data is not coming from report actually.

You could rename this into '_get_report_data'.

@sed-odoo sed-odoo force-pushed the odoo-dev:master-add-new-individual-account-report-sed branch Feb 19, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Feb 19, 2019

@tivisse tivisse force-pushed the odoo-dev:master-add-new-individual-account-report-sed branch Feb 19, 2019

[IMP] l10n_be_hr_payroll: Add 'Individual account' report
Purpose
=======

Add the possibility to generate the 'Compte Individuel' (or 'Individual Account')
based on the belgian payslip for a specific year.

This report aggregates the payslip lines by month, by quarter and for the entire
year.

@tivisse tivisse force-pushed the odoo-dev:master-add-new-individual-account-report-sed branch to 54c477a Feb 19, 2019

@tivisse

This comment has been minimized.

Copy link
Contributor Author

tivisse commented Feb 19, 2019

@robodoo

This comment has been minimized.

Copy link
Contributor

robodoo commented Feb 19, 2019

Linked pull request(s) odoo/enterprise#3609 not ready. Linked PRs are not staged until all of them are ready.

robodoo pushed a commit that referenced this pull request Feb 19, 2019

[IMP] l10n_be_hr_payroll: Add 'Individual account' report
Purpose
=======

Add the possibility to generate the 'Compte Individuel' (or 'Individual Account')
based on the belgian payslip for a specific year.

This report aggregates the payslip lines by month, by quarter and for the entire
year.

closes #30487
@robodoo

This comment has been minimized.

Copy link
Contributor

robodoo commented Feb 19, 2019

Merged, thanks!

@robodoo robodoo closed this Feb 19, 2019

@tivisse tivisse deleted the odoo-dev:master-add-new-individual-account-report-sed branch Feb 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.