[FIX] website_sale: website payment terms issue with portal users

Steps to reproduce the bug:
-create a child contact of a company C
-invite the child contact as a portal user
-sign into the website and place an order w/ wire transfer as payment acquirer

Bug:
The payment term set on the quotation was not taken from the company C and
the default sales person  was not taken from company C too.

opw:745091
This commit is contained in:
Goffin Simon
2017-06-14 16:14:53 +02:00
parent 8b886bd316
commit 6c94264f99
+3 -2
View File
@@ -316,7 +316,7 @@ class Website(models.Model):
@api.model
def sale_get_payment_term(self, partner):
DEFAULT_PAYMENT_TERM = 'account.account_payment_term_immediate'
return self.env.ref(DEFAULT_PAYMENT_TERM, False).id or partner.property_payment_term_id.id
return partner.property_payment_term_id.id or self.env.ref(DEFAULT_PAYMENT_TERM, False).id
@api.multi
def _prepare_sale_order_values(self, partner, pricelist):
@@ -324,6 +324,7 @@ class Website(models.Model):
affiliate_id = request.session.get('affiliate_id')
salesperson_id = affiliate_id if self.env['res.users'].sudo().browse(affiliate_id).exists() else request.website.salesperson_id.id
addr = partner.address_get(['delivery', 'invoice'])
default_user_id = partner.parent_id.user_id.id or partner.user_id.id
values = {
'partner_id': partner.id,
'pricelist_id': pricelist.id,
@@ -331,7 +332,7 @@ class Website(models.Model):
'team_id': self.salesteam_id.id,
'partner_invoice_id': addr['invoice'],
'partner_shipping_id': addr['delivery'],
'user_id': salesperson_id or self.salesperson_id.id,
'user_id': salesperson_id or self.salesperson_id.id or default_user_id,
}
company = self.company_id or pricelist.company_id
if company: