[MERGE] forward port branch saas-12 up to ff7f3d6
This commit is contained in:
@@ -155,6 +155,8 @@ class ReportAgedPartnerBalance(models.AbstractModel):
|
|||||||
history.append(partners_amount)
|
history.append(partners_amount)
|
||||||
|
|
||||||
for partner in partners:
|
for partner in partners:
|
||||||
|
if partner['partner_id'] is None:
|
||||||
|
partner['partner_id'] = False
|
||||||
at_least_one_amount = False
|
at_least_one_amount = False
|
||||||
values = {}
|
values = {}
|
||||||
undue_amt = 0.0
|
undue_amt = 0.0
|
||||||
|
|||||||
@@ -21,18 +21,33 @@ class PaypalController(http.Controller):
|
|||||||
""" Extract the return URL from the data coming from paypal. """
|
""" Extract the return URL from the data coming from paypal. """
|
||||||
return_url = post.pop('return_url', '')
|
return_url = post.pop('return_url', '')
|
||||||
if not return_url:
|
if not return_url:
|
||||||
custom = json.loads(post.pop('custom', False) or '{}')
|
custom = json.loads(post.pop('custom', False) or post.pop('cm', False) or '{}')
|
||||||
return_url = custom.get('return_url', '/')
|
return_url = custom.get('return_url', '/')
|
||||||
return return_url
|
return return_url
|
||||||
|
|
||||||
|
def _parse_pdt_response(self, response):
|
||||||
|
""" Parse a text reponse for a PDT verification .
|
||||||
|
|
||||||
|
:param response str: text response, structured in the following way:
|
||||||
|
STATUS\nkey1=value1\nkey2=value2...\n
|
||||||
|
:rtype tuple(str, dict)
|
||||||
|
:return: tuple containing the STATUS str and the key/value pairs
|
||||||
|
parsed as a dict
|
||||||
|
"""
|
||||||
|
lines = filter(None, response.split('\n'))
|
||||||
|
status = lines.pop(0)
|
||||||
|
pdt_post = dict(line.split('=', 1) for line in lines)
|
||||||
|
return status, pdt_post
|
||||||
|
|
||||||
def paypal_validate_data(self, **post):
|
def paypal_validate_data(self, **post):
|
||||||
""" Paypal IPN: three steps validation to ensure data correctness
|
""" Paypal IPN: three steps validation to ensure data correctness
|
||||||
|
|
||||||
- step 1: return an empty HTTP 200 response -> will be done at the end
|
- step 1: return an empty HTTP 200 response -> will be done at the end
|
||||||
by returning ''
|
by returning ''
|
||||||
- step 2: POST the complete, unaltered message back to Paypal (preceded
|
- step 2: POST the complete, unaltered message back to Paypal (preceded
|
||||||
by cmd=_notify-validate), with same encoding
|
by cmd=_notify-validate or _notify-synch for PDT), with same encoding
|
||||||
- step 3: paypal send either VERIFIED or INVALID (single word)
|
- step 3: paypal send either VERIFIED or INVALID (single word) for IPN
|
||||||
|
or SUCCESS or FAIL (+ data) for PDT
|
||||||
|
|
||||||
Once data is validated, process it. """
|
Once data is validated, process it. """
|
||||||
res = False
|
res = False
|
||||||
@@ -42,17 +57,25 @@ class PaypalController(http.Controller):
|
|||||||
if reference:
|
if reference:
|
||||||
tx = request.env['payment.transaction'].search([('reference', '=', reference)])
|
tx = request.env['payment.transaction'].search([('reference', '=', reference)])
|
||||||
paypal_urls = tx.acquirer_id._get_paypal_urls(tx.acquirer_id.environment or 'prod')
|
paypal_urls = tx.acquirer_id._get_paypal_urls(tx.acquirer_id.environment or 'prod')
|
||||||
|
pdt_request = bool(new_post.get('amt')) # check for spefific pdt param
|
||||||
|
if pdt_request:
|
||||||
|
# this means we are in PDT instead of DPN like before
|
||||||
|
# fetch the PDT token
|
||||||
|
new_post['at'] = request.env['ir.config_parameter'].sudo().get_param('payment_paypal.pdt_token')
|
||||||
|
new_post['cmd'] = '_notify-synch' # command is different in PDT than IPN/DPN
|
||||||
validate_url = paypal_urls['paypal_form_url']
|
validate_url = paypal_urls['paypal_form_url']
|
||||||
urequest = urllib2.Request(validate_url, werkzeug.url_encode(new_post))
|
urequest = urllib2.Request(validate_url, werkzeug.url_encode(new_post))
|
||||||
uopen = urllib2.urlopen(urequest)
|
uopen = urllib2.urlopen(urequest)
|
||||||
resp = uopen.read()
|
resp = uopen.read()
|
||||||
if resp == 'VERIFIED':
|
if pdt_request:
|
||||||
|
resp, post = self._parse_pdt_response(resp)
|
||||||
|
if resp == 'VERIFIED' or pdt_request and resp == 'SUCCESS':
|
||||||
_logger.info('Paypal: validated data')
|
_logger.info('Paypal: validated data')
|
||||||
res = request.env['payment.transaction'].sudo().form_feedback(post, 'paypal')
|
res = request.env['payment.transaction'].sudo().form_feedback(post, 'paypal')
|
||||||
elif resp == 'INVALID':
|
elif resp == 'INVALID' or pdt_request and resp == 'FAIL':
|
||||||
_logger.warning('Paypal: answered INVALID on data verification')
|
_logger.warning('Paypal: answered INVALID/FAIL on data verification')
|
||||||
else:
|
else:
|
||||||
_logger.warning('Paypal: unrecognized paypal answer, received %s instead of VERIFIED or INVALID' % resp.text)
|
_logger.warning('Paypal: unrecognized paypal answer, received %s instead of VERIFIED/SUCCESS or INVALID/FAIL (validation: %s)' % (resp, 'PDT' if pdt_request else 'IPN/DPN'))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@http.route('/payment/paypal/ipn/', type='http', auth='none', methods=['POST'], csrf=False)
|
@http.route('/payment/paypal/ipn/', type='http', auth='none', methods=['POST'], csrf=False)
|
||||||
|
|||||||
@@ -669,6 +669,10 @@ class SaleOrderLine(models.Model):
|
|||||||
new_procs.run()
|
new_procs.run()
|
||||||
return new_procs
|
return new_procs
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_purchase_price(self, pricelist, product, product_uom, date):
|
||||||
|
return {}
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, values):
|
def create(self, values):
|
||||||
onchange_fields = ['name', 'price_unit', 'product_uom', 'tax_id']
|
onchange_fields = ['name', 'price_unit', 'product_uom', 'tax_id']
|
||||||
|
|||||||
@@ -22,6 +22,18 @@ class SaleOrderLine(models.Model):
|
|||||||
price = frm_cur.with_context(ctx).compute(purchase_price, to_cur, round=False)
|
price = frm_cur.with_context(ctx).compute(purchase_price, to_cur, round=False)
|
||||||
return price
|
return price
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_purchase_price(self, pricelist, product, product_uom, date):
|
||||||
|
frm_cur = self.env.user.company_id.currency_id
|
||||||
|
to_cur = pricelist.currency_id
|
||||||
|
purchase_price = product.standard_price
|
||||||
|
if product_uom != product.uom_id:
|
||||||
|
purchase_price = self.env['product.uom']._compute_price(product.uom_id.id, purchase_price, to_uom_id=product_uom.id)
|
||||||
|
ctx = self.env.context.copy()
|
||||||
|
ctx['date'] = date
|
||||||
|
price = frm_cur.with_context(ctx).compute(purchase_price, to_cur, round=False)
|
||||||
|
return {'purchase_price': price}
|
||||||
|
|
||||||
@api.onchange('product_id', 'product_uom')
|
@api.onchange('product_id', 'product_uom')
|
||||||
def product_id_change_margin(self):
|
def product_id_change_margin(self):
|
||||||
if not self.order_id.pricelist_id or not self.product_id or not self.product_uom:
|
if not self.order_id.pricelist_id or not self.product_id or not self.product_uom:
|
||||||
|
|||||||
@@ -33,10 +33,8 @@ class CrmLead(models.Model):
|
|||||||
if not partner_assigned:
|
if not partner_assigned:
|
||||||
self.date_assign = False
|
self.date_assign = False
|
||||||
else:
|
else:
|
||||||
self.write({
|
self.date_assign = fields.Date.context_today(self)
|
||||||
'date_assign': fields.Date.context_today(self),
|
self.user_id = partner_assigned.user_id
|
||||||
'user_id': partner_assigned.user_id,
|
|
||||||
})
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def assign_salesman_of_assigned_partner(self):
|
def assign_salesman_of_assigned_partner(self):
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
<h3>The Team</h3>
|
<h3>The Team</h3>
|
||||||
<t t-foreach="team" t-as="user" class="media">
|
<t t-foreach="team" t-as="user" class="media">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="pull-left">
|
<div class="pull-left" t-if='user.image_small'>
|
||||||
<img t-att-src="user.image_small and ('data:image/png;base64,' + user.image_small) or '/web/static/src/img/placeholder.png'"
|
<img t-att-src="user.image_small and ('data:image/png;base64,' + user.image_small) or '/web/static/src/img/placeholder.png'"
|
||||||
class="img-rounded" t-att-alt="user.name"/>
|
class="img-rounded" t-att-alt="user.name"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ class SaleOrder(models.Model):
|
|||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'customer_lead': self._get_customer_lead(line.product_id.product_tmpl_id),
|
'customer_lead': self._get_customer_lead(line.product_id.product_tmpl_id),
|
||||||
}
|
}
|
||||||
|
if self.pricelist_id:
|
||||||
|
data.update(self.env['sale.order.line']._get_purchase_price(self.pricelist_id, line.product_id, line.product_uom_id, fields.Date.context_today(self)))
|
||||||
order_lines.append((0, 0, data))
|
order_lines.append((0, 0, data))
|
||||||
|
|
||||||
self.order_line = order_lines
|
self.order_line = order_lines
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class ResPartnerBank(models.Model):
|
|||||||
company_id = fields.Many2one('res.company', 'Company', default=lambda self: self.env.user.company_id, ondelete='cascade')
|
company_id = fields.Many2one('res.company', 'Company', default=lambda self: self.env.user.company_id, ondelete='cascade')
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('unique_number', 'unique(sanitized_acc_number)', 'Account Number must be unique'),
|
('unique_number', 'unique(sanitized_acc_number, company_id)', 'Account Number must be unique'),
|
||||||
]
|
]
|
||||||
|
|
||||||
@api.depends('acc_number')
|
@api.depends('acc_number')
|
||||||
|
|||||||
Reference in New Issue
Block a user