bank-payment/account_payment_purchase_stock/models/stock_rule.py

23 lines
792 B
Python
Raw Normal View History

2021-03-12 16:21:19 +00:00
# Copyright 2015 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from flectra import models
class StockRule(models.Model):
_inherit = "stock.rule"
def _prepare_purchase_order(self, company_id, origins, values):
"""Propagate payment mode on MTO/drop shipping."""
res = super()._prepare_purchase_order(company_id, origins, values)
values = values[0]
partner = values["supplier"].name
if partner:
res["payment_mode_id"] = partner.with_company(
self.company_id.id
).supplier_payment_mode_id.id
res["supplier_partner_bank_id"] = self.env[
"purchase.order"
]._get_default_supplier_partner_bank(partner)
return res