diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-04-25 17:29:34 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-04-25 17:29:34 +0200 |
| commit | da60ca91cc446c10eda5cbfc451cf5501f30a81d (patch) | |
| tree | f10eaf90245d50b3cc98c6e5730edcc10f89073f | |
| parent | 4d337f72ed59d1e5260fa2bb4f3d238e6ed11415 (diff) | |
| parent | e24888205375ecf6d6ad2832ce7cbaee0c5edf89 (diff) | |
[MERGE] forward port of branch 9.0 up to e248882
| -rw-r--r-- | addons/account/wizard/account_invoice_refund.py | 2 | ||||
| -rw-r--r-- | addons/sale/sale.py | 13 | ||||
| -rw-r--r-- | openerp/addons/base/ir/ir_http.py | 4 |
3 files changed, 18 insertions, 1 deletions
diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index 226b3e711f8..638b0e1fc1e 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -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({ diff --git a/addons/sale/sale.py b/addons/sale/sale.py index ea46e64b6be..431df9b36dd 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -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' diff --git a/openerp/addons/base/ir/ir_http.py b/openerp/addons/base/ir/ir_http.py index 72e66e24c33..5148b11c8d8 100644 --- a/openerp/addons/base/ir/ir_http.py +++ b/openerp/addons/base/ir/ir_http.py @@ -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)) |
