[IMP] pre-commit: first run on whole repo
This commit is contained in:
@@ -2,62 +2,65 @@
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class AccountBankStatementSale(models.TransientModel):
|
||||
_name = 'account.bank.statement.sale'
|
||||
_description = 'Account Bank Statement Sale'
|
||||
_name = "account.bank.statement.sale"
|
||||
_description = "Account Bank Statement Sale"
|
||||
|
||||
statement_id = fields.Many2one('account.bank.statement', readonly=True)
|
||||
statement_id = fields.Many2one("account.bank.statement", readonly=True)
|
||||
line_ids = fields.One2many(
|
||||
'account.bank.statement.sale.line', 'wizard_id', string='Lines')
|
||||
"account.bank.statement.sale.line", "wizard_id", string="Lines"
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _prepare_line(self, move_line):
|
||||
vals = {
|
||||
'move_line_id': move_line.id,
|
||||
'sale_id': move_line.sale_id.id or False,
|
||||
'date': move_line.date,
|
||||
'credit': move_line.credit,
|
||||
'partner_id': move_line.partner_id.id,
|
||||
'account_id': move_line.account_id.id,
|
||||
'name': move_line.name,
|
||||
'company_currency_id': move_line.company_currency_id.id,
|
||||
}
|
||||
"move_line_id": move_line.id,
|
||||
"sale_id": move_line.sale_id.id or False,
|
||||
"date": move_line.date,
|
||||
"credit": move_line.credit,
|
||||
"partner_id": move_line.partner_id.id,
|
||||
"account_id": move_line.account_id.id,
|
||||
"name": move_line.name,
|
||||
"company_currency_id": move_line.company_currency_id.id,
|
||||
}
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super(AccountBankStatementSale, self).default_get(fields_list)
|
||||
assert self._context.get('active_model') == 'account.bank.statement'
|
||||
statement_id = self._context.get('active_id')
|
||||
statement = self.env['account.bank.statement'].browse(statement_id)
|
||||
res.update({
|
||||
'line_ids': [],
|
||||
'statement_id': statement_id,
|
||||
})
|
||||
assert self._context.get("active_model") == "account.bank.statement"
|
||||
statement_id = self._context.get("active_id")
|
||||
statement = self.env["account.bank.statement"].browse(statement_id)
|
||||
res.update(
|
||||
{
|
||||
"line_ids": [],
|
||||
"statement_id": statement_id,
|
||||
}
|
||||
)
|
||||
for st_line in statement.line_ids:
|
||||
if (
|
||||
st_line.amount > 0 and
|
||||
st_line.partner_id and
|
||||
st_line.journal_entry_ids):
|
||||
if st_line.amount > 0 and st_line.partner_id and st_line.journal_entry_ids:
|
||||
for line in st_line.journal_entry_ids:
|
||||
if (
|
||||
line.account_id.user_type_id.type == 'receivable'
|
||||
and
|
||||
line.partner_id and
|
||||
not line.full_reconcile_id and
|
||||
not line.matched_debit_ids and
|
||||
not line.matched_credit_ids):
|
||||
line.account_id.user_type_id.type == "receivable"
|
||||
and line.partner_id
|
||||
and not line.full_reconcile_id
|
||||
and not line.matched_debit_ids
|
||||
and not line.matched_credit_ids
|
||||
):
|
||||
lvals = self._prepare_line(line)
|
||||
res['line_ids'].append((0, 0, lvals))
|
||||
if not res['line_ids']:
|
||||
raise UserError(_(
|
||||
"The bank statement '%s' doesn't contain any processed line "
|
||||
"with a positive amount which is not reconciled.")
|
||||
% statement.display_name)
|
||||
res["line_ids"].append((0, 0, lvals))
|
||||
if not res["line_ids"]:
|
||||
raise UserError(
|
||||
_(
|
||||
"The bank statement '%s' doesn't contain any processed line "
|
||||
"with a positive amount which is not reconciled."
|
||||
)
|
||||
% statement.display_name
|
||||
)
|
||||
return res
|
||||
|
||||
def validate(self):
|
||||
@@ -68,19 +71,19 @@ class AccountBankStatementSale(models.TransientModel):
|
||||
|
||||
|
||||
class AccountBankStatementSaleLine(models.TransientModel):
|
||||
_name = 'account.bank.statement.sale.line'
|
||||
_description = 'Account Bank Statement Sale Lines'
|
||||
_name = "account.bank.statement.sale.line"
|
||||
_description = "Account Bank Statement Sale Lines"
|
||||
|
||||
wizard_id = fields.Many2one(
|
||||
'account.bank.statement.sale', ondelete='cascade')
|
||||
wizard_id = fields.Many2one("account.bank.statement.sale", ondelete="cascade")
|
||||
move_line_id = fields.Many2one(
|
||||
'account.move.line', string='Move Line', required=True)
|
||||
date = fields.Date(related='move_line_id.date')
|
||||
"account.move.line", string="Move Line", required=True
|
||||
)
|
||||
date = fields.Date(related="move_line_id.date")
|
||||
credit = fields.Monetary(
|
||||
related='move_line_id.credit', currency_field='company_currency_id')
|
||||
partner_id = fields.Many2one(related='move_line_id.partner_id')
|
||||
account_id = fields.Many2one(related='move_line_id.account_id')
|
||||
name = fields.Char(related='move_line_id.name')
|
||||
company_currency_id = fields.Many2one(
|
||||
related='move_line_id.company_currency_id')
|
||||
sale_id = fields.Many2one('sale.order', string='Sale Order')
|
||||
related="move_line_id.credit", currency_field="company_currency_id"
|
||||
)
|
||||
partner_id = fields.Many2one(related="move_line_id.partner_id")
|
||||
account_id = fields.Many2one(related="move_line_id.account_id")
|
||||
name = fields.Char(related="move_line_id.name")
|
||||
company_currency_id = fields.Many2one(related="move_line_id.company_currency_id")
|
||||
sale_id = fields.Many2one("sale.order", string="Sale Order")
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2019 Akretion France (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
|
||||
@@ -14,25 +13,33 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Link to Quotation/Sale Orders">
|
||||
<group name="main" invisible="1">
|
||||
<field name="statement_id"/>
|
||||
<field name="statement_id" />
|
||||
</group>
|
||||
<group name="lines">
|
||||
<field name="line_ids" nolabel="1">
|
||||
<tree editable="bottom">
|
||||
<field name="move_line_id" invisible="1"/>
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="account_id"/>
|
||||
<field name="credit"/>
|
||||
<field name="sale_id" domain="['|', ('partner_id', 'child_of', partner_id), ('partner_invoice_id', 'child_of', partner_id), ('state', '!=', 'cancel'), ('invoice_status', '!=', 'invoiced')]"/>
|
||||
<field name="company_currency_id" invisible="1"/>
|
||||
<field name="move_line_id" invisible="1" />
|
||||
<field name="date" />
|
||||
<field name="name" />
|
||||
<field name="partner_id" />
|
||||
<field name="account_id" />
|
||||
<field name="credit" />
|
||||
<field
|
||||
name="sale_id"
|
||||
domain="['|', ('partner_id', 'child_of', partner_id), ('partner_invoice_id', 'child_of', partner_id), ('state', '!=', 'cancel'), ('invoice_status', '!=', 'invoiced')]"
|
||||
/>
|
||||
<field name="company_currency_id" invisible="1" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="validate" type="object" string="Validate" class="btn-primary"/>
|
||||
<button special="cancel" string="Cancel" class="btn-default"/>
|
||||
<button
|
||||
name="validate"
|
||||
type="object"
|
||||
string="Validate"
|
||||
class="btn-primary"
|
||||
/>
|
||||
<button special="cancel" string="Cancel" class="btn-default" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user