[IMP] account_payment_sale: black, isort

This commit is contained in:
Raf Ven
2019-11-08 11:29:07 +01:00
committed by Atchuthan Ubendran
parent d5d1f970b8
commit ee54904589
5 changed files with 84 additions and 81 deletions

View File

@@ -3,22 +3,14 @@
# @author Alexis de Lattre <alexis.delattre@akretion.com>
{
'name': 'Account Payment Sale',
'version': '12.0.1.1.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': "Adds payment mode on sale orders",
'author': "Akretion, "
"Tecnativa, "
"Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/bank-payment',
'depends': [
'sale',
'account_payment_partner',
],
'data': [
'views/sale_order_view.xml',
'views/sale_report_templates.xml',
],
'auto_install': True,
"name": "Account Payment Sale",
"version": "12.0.1.1.0",
"category": "Banking addons",
"license": "AGPL-3",
"summary": "Adds payment mode on sale orders",
"author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/bank-payment",
"depends": ["sale", "account_payment_partner"],
"data": ["views/sale_order_view.xml", "views/sale_report_templates.xml"],
"auto_install": True,
}

View File

@@ -1,25 +1,28 @@
# Copyright 2014-2016 Akretion - Alexis de Lattre
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
from odoo import api, fields, models
class SaleOrder(models.Model):
_inherit = "sale.order"
payment_mode_id = fields.Many2one(
'account.payment.mode', string='Payment Mode',
domain=[('payment_type', '=', 'inbound')])
"account.payment.mode",
string="Payment Mode",
domain=[("payment_type", "=", "inbound")],
)
def _get_payment_mode_vals(self, vals):
if self.payment_mode_id:
vals['payment_mode_id'] = self.payment_mode_id.id
if self.payment_mode_id.bank_account_link == 'fixed':
vals['partner_bank_id'] =\
self.payment_mode_id.fixed_journal_id.bank_account_id.id
vals["payment_mode_id"] = self.payment_mode_id.id
if self.payment_mode_id.bank_account_link == "fixed":
vals[
"partner_bank_id"
] = self.payment_mode_id.fixed_journal_id.bank_account_id.id
return vals
@api.onchange('partner_id')
@api.onchange("partner_id")
def onchange_partner_id(self):
res = super().onchange_partner_id()
if self.partner_id:
@@ -48,13 +51,13 @@ class SaleOrder(models.Model):
payment_vals_by_invoice = {}
for invoice in invoices.values():
payment_vals_by_invoice[invoice] = {
'payment_mode_id': invoice.payment_mode_id.id,
'partner_bank_id': invoice.partner_bank_id.id
"payment_mode_id": invoice.payment_mode_id.id,
"partner_bank_id": invoice.partner_bank_id.id,
}
res = super()._finalize_invoices(invoices, references)
for invoice in invoices.values():
payment_vals = payment_vals_by_invoice[invoice]
if invoice.payment_mode_id.id == payment_vals['payment_mode_id']:
if invoice.payment_mode_id.id == payment_vals["payment_mode_id"]:
payment_vals.pop("payment_mode_id")
if invoice.partner_bank_id.id == payment_vals["partner_bank_id"]:
payment_vals.pop("partner_bank_id")

View File

@@ -5,56 +5,66 @@ from odoo.tests.common import SavepointCase
class CommonTestCase(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.bank = cls.env["res.partner.bank"].create({
'acc_number': 'test',
'partner_id': cls.env.user.company_id.partner_id.id,
})
cls.journal = cls.env["account.journal"].create({
'name': 'test journal',
'code': '123',
'type': 'bank',
'company_id': cls.env.ref("base.main_company").id,
'bank_account_id': cls.bank.id,
})
cls.payment_mode = cls.env["account.payment.mode"].create({
'name': 'test_mode',
'active': True,
'payment_method_id': cls.env.ref(
"account.account_payment_method_manual_in"
).id,
'bank_account_link': 'fixed',
'fixed_journal_id': cls.journal.id,
})
cls.payment_mode_2 = cls.env["account.payment.mode"].create({
'name': 'test_mode_2',
'active': True,
'payment_method_id': cls.env.ref(
"account.account_payment_method_manual_in"
).id,
'bank_account_link': 'fixed',
'fixed_journal_id': cls.journal.id,
})
cls.base_partner = cls.env["res.partner"].create({
'name': 'Dummy',
'email': 'dummy@example.com',
'customer_payment_mode_id': cls.payment_mode.id,
})
cls.bank = cls.env["res.partner.bank"].create(
{"acc_number": "test", "partner_id": cls.env.user.company_id.partner_id.id}
)
cls.journal = cls.env["account.journal"].create(
{
"name": "test journal",
"code": "123",
"type": "bank",
"company_id": cls.env.ref("base.main_company").id,
"bank_account_id": cls.bank.id,
}
)
cls.payment_mode = cls.env["account.payment.mode"].create(
{
"name": "test_mode",
"active": True,
"payment_method_id": cls.env.ref(
"account.account_payment_method_manual_in"
).id,
"bank_account_link": "fixed",
"fixed_journal_id": cls.journal.id,
}
)
cls.payment_mode_2 = cls.env["account.payment.mode"].create(
{
"name": "test_mode_2",
"active": True,
"payment_method_id": cls.env.ref(
"account.account_payment_method_manual_in"
).id,
"bank_account_link": "fixed",
"fixed_journal_id": cls.journal.id,
}
)
cls.base_partner = cls.env["res.partner"].create(
{
"name": "Dummy",
"email": "dummy@example.com",
"customer_payment_mode_id": cls.payment_mode.id,
}
)
cls.products = {
'prod_order': cls.env.ref('product.product_order_01'),
'prod_del': cls.env.ref('product.product_delivery_01'),
'serv_order': cls.env['product.product'].create({
'name': 'Test service product order',
'type': 'service',
'invoice_policy': 'order',
}),
'serv_del': cls.env['product.product'].create({
'name': 'Test service product delivery',
'type': 'service',
'invoice_policy': 'delivery',
}),
"prod_order": cls.env.ref("product.product_order_01"),
"prod_del": cls.env.ref("product.product_delivery_01"),
"serv_order": cls.env["product.product"].create(
{
"name": "Test service product order",
"type": "service",
"invoice_policy": "order",
}
),
"serv_del": cls.env["product.product"].create(
{
"name": "Test service product delivery",
"type": "service",
"invoice_policy": "delivery",
}
),
}

View File

@@ -31,9 +31,7 @@ class TestSaleOrder(CommonTestCase):
)
self.assertFalse(so.payment_mode_id)
so.onchange_partner_id()
self.assertEqual(
so.payment_mode_id, self.base_partner.customer_payment_mode_id
)
self.assertEqual(so.payment_mode_id, self.base_partner.customer_payment_mode_id)
# force payment mode
if payment_mode:
so.payment_mode_id = payment_mode.id

View File

@@ -1,11 +1,11 @@
# Copyright 2016 Akretion - Alexis de Lattre
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api
from odoo import api, models
class SaleAdvancePaymentInv(models.TransientModel):
_inherit = 'sale.advance.payment.inv'
_inherit = "sale.advance.payment.inv"
@api.multi
def _create_invoice(self, order, so_line, amount):