[IMP] partner_statement: black, isort

This commit is contained in:
mreficent
2020-02-04 11:45:07 +01:00
committed by Miquel Raïch
parent 588a2b54a7
commit 24cb1fe10c
20 changed files with 855 additions and 649 deletions

View File

@@ -2,38 +2,37 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
class StatementCommon(models.AbstractModel):
_name = 'statement.common.wizard'
_description = 'Statement Reports Common Wizard'
_name = "statement.common.wizard"
_description = "Statement Reports Common Wizard"
def _get_company(self):
return (
self.env['res.company'].browse(
self.env.context.get('force_company')) or
self.env.user.company_id
self.env["res.company"].browse(self.env.context.get("force_company"))
or self.env.user.company_id
)
name = fields.Char()
company_id = fields.Many2one(
comodel_name='res.company',
comodel_name="res.company",
default=_get_company,
string='Company',
string="Company",
required=True,
)
date_end = fields.Date(required=True, default=fields.Date.context_today)
show_aging_buckets = fields.Boolean(default=True)
number_partner_ids = fields.Integer(
default=lambda self: len(self._context['active_ids'])
default=lambda self: len(self._context["active_ids"])
)
filter_partners_non_due = fields.Boolean(
string="Don't show partners with no due entries", default=True)
filter_negative_balances = fields.Boolean(
"Exclude Negative Balances", default=True
string="Don't show partners with no due entries", default=True
)
filter_negative_balances = fields.Boolean("Exclude Negative Balances", default=True)
aging_type = fields.Selection(
[("days", "Age by Days"), ("months", "Age by Months")],
@@ -43,16 +42,17 @@ class StatementCommon(models.AbstractModel):
)
account_type = fields.Selection(
[('receivable', 'Receivable'),
('payable', 'Payable')], string='Account type', default='receivable')
[("receivable", "Receivable"), ("payable", "Payable")],
string="Account type",
default="receivable",
)
@api.onchange('aging_type')
@api.onchange("aging_type")
def onchange_aging_type(self):
if self.aging_type == 'months':
self.date_end = (
fields.Date.context_today(self).replace(day=1) -
relativedelta(days=1)
)
if self.aging_type == "months":
self.date_end = fields.Date.context_today(self).replace(
day=1
) - relativedelta(days=1)
else:
self.date_end = fields.Date.context_today(self)
@@ -64,14 +64,14 @@ class StatementCommon(models.AbstractModel):
def _prepare_statement(self):
self.ensure_one()
return {
'date_end': self.date_end,
'company_id': self.company_id.id,
'partner_ids': self._context['active_ids'],
'show_aging_buckets': self.show_aging_buckets,
'filter_non_due_partners': self.filter_partners_non_due,
'account_type': self.account_type,
'aging_type': self.aging_type,
'filter_negative_balances': self.filter_negative_balances,
"date_end": self.date_end,
"company_id": self.company_id.id,
"partner_ids": self._context["active_ids"],
"show_aging_buckets": self.show_aging_buckets,
"filter_non_due_partners": self.filter_partners_non_due,
"account_type": self.account_type,
"aging_type": self.aging_type,
"filter_negative_balances": self.filter_negative_balances,
}
def _export(self):