[MERGE] forward port branch saas-14 up to 68d1ad5b7a
This commit is contained in:
@@ -821,6 +821,9 @@ class AccountBankStatementLine(models.Model):
|
||||
}
|
||||
st_line.process_reconciliation(new_aml_dicts=[vals])
|
||||
|
||||
def _get_communication(self, payment_method_id):
|
||||
return self.name or ''
|
||||
|
||||
def process_reconciliation(self, counterpart_aml_dicts=None, payment_aml_rec=None, new_aml_dicts=None):
|
||||
""" Match statement lines with existing payments (eg. checks) and/or payables/receivables (eg. invoices and refunds) and/or new move lines (eg. write-offs).
|
||||
If any new journal item needs to be created (via new_aml_dicts or counterpart_aml_dicts), a new journal entry will be created and will contain those
|
||||
@@ -918,7 +921,7 @@ class AccountBankStatementLine(models.Model):
|
||||
'state': 'reconciled',
|
||||
'currency_id': currency.id,
|
||||
'amount': abs(total),
|
||||
'communication': self.name or '',
|
||||
'communication': self._get_communication(payment_methods[0] if payment_methods else False),
|
||||
'name': self.statement_id.name,
|
||||
})
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ class ResPartner(models.Model):
|
||||
|
||||
# generate where clause to include multicompany rules
|
||||
where_query = account_invoice_report._where_calc([
|
||||
('partner_id', 'in', all_partner_ids), ('state', 'not in', ['draft', 'cancel']), ('company_id', '=', self.env.user.company_id.id),
|
||||
('partner_id', 'in', all_partner_ids), ('state', 'not in', ['draft', 'cancel']),
|
||||
('type', 'in', ('out_invoice', 'out_refund'))
|
||||
])
|
||||
account_invoice_report._apply_ir_rules(where_query, 'read')
|
||||
|
||||
@@ -134,7 +134,7 @@ class AccountInvoiceReport(models.Model):
|
||||
JOIN (
|
||||
-- Temporary table to decide if the qty should be added or retrieved (Invoice vs Refund)
|
||||
SELECT id,(CASE
|
||||
WHEN ai.type::text = ANY (ARRAY['out_refund'::character varying::text, 'in_invoice'::character varying::text])
|
||||
WHEN ai.type::text = ANY (ARRAY['in_refund'::character varying::text, 'in_invoice'::character varying::text])
|
||||
THEN -1
|
||||
ELSE 1
|
||||
END) AS sign
|
||||
|
||||
@@ -86,3 +86,15 @@ class StockConfigSettings(models.TransientModel):
|
||||
warehouses.mapped('int_type_id').write({'active': active})
|
||||
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def get_default_decimal_precision(self, fields):
|
||||
# don't forward-port in v11.0, the API of config wizards changed.
|
||||
digits = self.env.ref('product.decimal_stock_weight').digits
|
||||
return {'decimal_precision': digits}
|
||||
|
||||
@api.multi
|
||||
def set_decimal_precision(self):
|
||||
# don't forward-port in v11.0, the API of config wizards changed.
|
||||
for record in self:
|
||||
self.env.ref('product.decimal_stock_weight').write({'digits': record.decimal_precision})
|
||||
|
||||
@@ -663,6 +663,30 @@ class TestFields(common.TransactionCase):
|
||||
self.assertFalse(discussion.very_important_messages)
|
||||
self.assertFalse(message.exists())
|
||||
|
||||
def test_70_x2many_write(self):
|
||||
discussion = self.env.ref('test_new_api.discussion_0')
|
||||
Message = self.env['test_new_api.message']
|
||||
# There must be 3 messages, 0 important
|
||||
self.assertEqual(len(discussion.messages), 3)
|
||||
self.assertEqual(len(discussion.important_messages), 0)
|
||||
self.assertEqual(len(discussion.very_important_messages), 0)
|
||||
discussion.important_messages = [(0, 0, {
|
||||
'body': 'What is the answer?',
|
||||
'important': True,
|
||||
})]
|
||||
# There must be 4 messages, 1 important
|
||||
self.assertEqual(len(discussion.messages), 4)
|
||||
self.assertEqual(len(discussion.important_messages), 1)
|
||||
self.assertEqual(len(discussion.very_important_messages), 1)
|
||||
discussion.very_important_messages |= Message.new({
|
||||
'body': '42',
|
||||
'important': True,
|
||||
})
|
||||
# There must be 5 messages, 2 important
|
||||
self.assertEqual(len(discussion.messages), 5)
|
||||
self.assertEqual(len(discussion.important_messages), 2)
|
||||
self.assertEqual(len(discussion.very_important_messages), 2)
|
||||
|
||||
|
||||
class TestHtmlField(common.TransactionCase):
|
||||
|
||||
|
||||
+4
-5
@@ -2289,14 +2289,13 @@ class One2many(_RelationalMulti):
|
||||
elif act[0] == 6:
|
||||
record = records[-1]
|
||||
comodel.browse(act[2]).write({inverse: record.id})
|
||||
query = "SELECT id FROM %s WHERE %s=%%s AND id <> ALL(%%s)" % (comodel._table, inverse)
|
||||
comodel._cr.execute(query, (record.id, act[2] or [0]))
|
||||
lines = comodel.browse([row[0] for row in comodel._cr.fetchall()])
|
||||
domain = self.domain(records) if callable(self.domain) else self.domain
|
||||
domain = domain + [(inverse, 'in', records.ids), ('id', 'not in', act[2] or [0])]
|
||||
inverse_field = comodel._fields[inverse]
|
||||
if inverse_field.ondelete == 'cascade':
|
||||
lines.unlink()
|
||||
comodel.search(domain).unlink()
|
||||
else:
|
||||
lines.write({inverse: False})
|
||||
comodel.search(domain).write({inverse: False})
|
||||
|
||||
|
||||
class Many2many(_RelationalMulti):
|
||||
|
||||
Reference in New Issue
Block a user