[MERGE] forward port of branch 9.0 up to e248882
This commit is contained in:
@@ -87,7 +87,7 @@ class AccountInvoiceRefund(models.TransientModel):
|
||||
invoice = invoice[0]
|
||||
del invoice['id']
|
||||
invoice_lines = inv_line_obj.browse(invoice['invoice_line_ids'])
|
||||
invoice_lines = inv_obj._refund_cleanup_lines(invoice_lines)
|
||||
invoice_lines = inv_obj.with_context(mode='modify')._refund_cleanup_lines(invoice_lines)
|
||||
tax_lines = inv_tax_obj.browse(invoice['tax_line_ids'])
|
||||
tax_lines = inv_obj._refund_cleanup_lines(tax_lines)
|
||||
invoice.update({
|
||||
|
||||
@@ -52,6 +52,9 @@ class SaleOrder(models.Model):
|
||||
"""
|
||||
for order in self:
|
||||
invoice_ids = order.order_line.mapped('invoice_lines').mapped('invoice_id')
|
||||
# Search for invoices which have been 'cancelled' (filter_refund = 'modify' in
|
||||
# 'account.invoice.refund')
|
||||
invoice_ids |= invoice_ids.search([('origin', 'like', order.name)])
|
||||
# Search for refunds as well
|
||||
refund_ids = self.env['account.invoice'].browse()
|
||||
if invoice_ids:
|
||||
@@ -833,6 +836,16 @@ class AccountInvoice(models.Model):
|
||||
order.message_post(body=_("Invoice %s paid") % (name))
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _refund_cleanup_lines(self, lines):
|
||||
result = super(AccountInvoice, self)._refund_cleanup_lines(lines)
|
||||
if self.env.context.get('mode') == 'modify':
|
||||
for i in xrange(0, len(lines)):
|
||||
for name, field in lines[i]._fields.iteritems():
|
||||
if name == 'sale_line_ids':
|
||||
result[i][2][name] = [(6, 0, lines[i][name].ids)]
|
||||
lines[i][name] = False
|
||||
return result
|
||||
|
||||
class AccountInvoiceLine(models.Model):
|
||||
_inherit = 'account.invoice.line'
|
||||
|
||||
@@ -300,6 +300,10 @@ class ir_http(osv.AbstractModel):
|
||||
mimetype = obj.mimetype
|
||||
elif filename:
|
||||
mimetype = mimetypes.guess_type(filename)[0]
|
||||
elif getattr(env[model]._fields[field], 'attachment', False):
|
||||
# for binary fields, fetch the ir_attachement for mimetype check
|
||||
attach_mimetype = env['ir.attachment'].search_read(domain=[('res_model', '=', model), ('res_id', '=', id), ('res_field', '=', field)], fields=['mimetype'], limit=1)
|
||||
mimetype = attach_mimetype and attach_mimetype[0]['mimetype']
|
||||
if not mimetype:
|
||||
mimetype = default_mimetype
|
||||
headers.append(('Content-Type', mimetype))
|
||||
|
||||
Reference in New Issue
Block a user