Skip to content

Commit

Permalink
[MERGE] forward port branch saas-11 up to c2569b9
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Mar 28, 2017
2 parents 0dbc8b0 + c2569b9 commit 2749673
Show file tree
Hide file tree
Showing 68 changed files with 1,828 additions and 405 deletions.
11 changes: 10 additions & 1 deletion addons/account/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ def write(self, vals):
if 'bank_acc_number' in vals:
for journal in self.filtered(lambda r: r.type == 'bank' and not r.bank_account_id):
journal.set_bank_account(vals.get('bank_acc_number'), vals.get('bank_id'))
# create the relevant refund sequence
if vals.get('refund_sequence'):
for journal in self.filtered(lambda j: j.type in ('sale', 'purchase') and not j.refund_sequence_id):
journal_vals = {
'name': journal.name,
'company_id': journal.company_id.id,
'code': journal.code
}
journal.refund_sequence_id = self.sudo()._create_sequence(journal_vals, refund=True).id

return result

Expand All @@ -385,7 +394,7 @@ def _create_sequence(self, vals, refund=False):
""" Create new no_gap entry sequence for every new Journal"""
prefix = self._get_sequence_prefix(vals['code'], refund)
seq = {
'name': vals['name'],
'name': refund and vals['name'] + _(': Refund') or vals['name'],
'implementation': 'no_gap',
'prefix': prefix,
'padding': 4,
Expand Down
2 changes: 1 addition & 1 deletion addons/account/models/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def get_move_lines_for_reconciliation(self, excluded_ids=None, str=False, offset
domain_reconciliation = ['&', '&', ('statement_id', '=', False), ('account_id', 'in', reconciliation_aml_accounts), ('payment_id','<>', False)]

# Black lines = unreconciled & (not linked to a payment or open balance created by statement
domain_matching = ['&', ('reconciled', '=', False), '|', ('payment_id','=',False), ('statement_id', '<>', False)]
domain_matching = [('reconciled', '=', False)]
if self.partner_id.id or overlook_partner:
domain_matching = expression.AND([domain_matching, [('account_id.internal_type', 'in', ['payable', 'receivable'])]])
else:
Expand Down
2 changes: 1 addition & 1 deletion addons/account/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def _compute_payments(self):
default=lambda self: self.env.user)
fiscal_position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', oldname='fiscal_position',
readonly=True, states={'draft': [('readonly', False)]})
commercial_partner_id = fields.Many2one('res.partner', string='Commercial Entity',
commercial_partner_id = fields.Many2one('res.partner', string='Commercial Entity', compute_sudo=True,
related='partner_id.commercial_partner_id', store=True, readonly=True,
help="The commercial entity that will be used on Journal Entries for this invoice")

Expand Down
9 changes: 9 additions & 0 deletions addons/account/models/company.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from odoo import fields, models, api, _
from odoo.exceptions import ValidationError
from datetime import timedelta


Expand Down Expand Up @@ -79,6 +80,14 @@ def reflect_code_digits_change(self, digits):

@api.multi
def write(self, values):
#restrict the closing of FY if there are still unposted entries
if values.get('fiscalyear_lock_date'):
nb_draft_entries = self.env['account.move'].search([
('company_id', 'in', [c.id for c in self]),
('state', '=', 'draft'),
('date', '<=', values['fiscalyear_lock_date'])])
if nb_draft_entries:
raise ValidationError(_('There are still unposted entries in the period you want to lock. You should either post or delete them.'))
# Reflect the change on accounts
for company in self:
digits = values.get('accounts_code_digits') or company.accounts_code_digits
Expand Down
9 changes: 7 additions & 2 deletions addons/account/tests/test_account_move_closed_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ class TestPeriodState(AccountingTestCase):

def setUp(self):
super(TestPeriodState, self).setUp()
self.user_id = self.env.user
self.day_before_yesterday = datetime.now() - timedelta(2)
self.yesterday = datetime.now() - timedelta(1)
self.user_id = self.env.user
self.user_id.company_id.write({'fiscalyear_lock_date': self.yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)})
self.yesterday_str = self.yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)
#make sure there is no unposted entry
draft_entries = self.env['account.move'].search([('date', '<=', self.yesterday_str), ('state', '=', 'draft')])
if draft_entries:
draft_entries.post()
self.user_id.company_id.write({'fiscalyear_lock_date': self.yesterday_str})
self.sale_journal_id = self.env['account.journal'].search([('type', '=', 'sale')])[0]
self.account_id = self.env['account.account'].search([('internal_type', '=', 'receivable')])[0]

Expand Down
2 changes: 1 addition & 1 deletion addons/account/views/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
<field name="code"/>
<field name="refund_sequence" attrs="{'invisible': [('type', 'not in', ['sale', 'purchase'])]}" groups="base.group_no_one"/>
<field name="sequence_id" required="0" attrs="{'readonly': 1}" groups="base.group_no_one"/>
<field name="refund_sequence_id" attrs="{'invisible': ['|',('type', 'not in', ['sale', 'purchase']), ('refund_sequence', '!=', True)], 'required': [('type', 'in', ['sale', 'purchase']), ('refund_sequence', '=', True)]}"/>
<field name="refund_sequence_id" required="0" attrs="{'readonly': 1, 'invisible': ['|',('type', 'not in', ['sale', 'purchase']), ('refund_sequence', '!=', True)]}" groups="base.group_no_one"/>
</group>
<group>
<field name="default_debit_account_id" domain="[('deprecated', '=', False)]" />
Expand Down
1 change: 0 additions & 1 deletion addons/account_check_printing/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def print_checks(self):
}
else:
self.filtered(lambda r: r.state == 'draft').post()
self.write({'state': 'sent'})
return self.do_print_checks()

@api.multi
Expand Down
1 change: 1 addition & 0 deletions addons/barcodes/static/src/js/barcode_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
if (e.key === "ArrowLeft" || e.key === "ArrowRight" ||
e.key === "ArrowUp" || e.key === "ArrowDown" ||
e.key === "Escape" || e.key === "Tab" ||
e.key === "Backspace" || e.key === "Delete" ||
/F\d\d?/.test(e.key)) {
return true;
} else {
Expand Down
4 changes: 4 additions & 0 deletions addons/barcodes/static/src/js/field_float_scannable.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ var FieldFloatScannable = form_widgets.FieldFloat.extend({
},

simulateKeypress: function (e) {
/* only simulate a keypress if it has been previously prevented */
if (e.originalEvent.dispatched_by_barcode_reader !== true) {
return;
}
var character = String.fromCharCode(e.which);
var current_str = e.target.value;
var str_before_carret = current_str.substring(0, e.target.selectionStart);
Expand Down
34 changes: 34 additions & 0 deletions addons/base_action_rule/data/base_action_rule_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,44 @@
<field name="filter_domain">[('customer', '=', True)]</field>
</record>

<record id="test_action" model="ir.actions.server">
<field name="name">Test Server Action</field>
<field name="model_id" ref="base_action_rule.model_base_action_rule_lead_test"/>
<field name="code">
record = model.browse(context['active_id'])
if 'partner_id' in context['old_values'][record.id]:
record.write({'state': 'draft'})
</field>
</record>

<record id="test_rule_recursive" model="base.action.rule">
<field name="name">Test recursive rule</field>
<field name="kind">on_write</field>
<field name="model_id" ref="base_action_rule.model_base_action_rule_lead_test"/>
<field name="server_action_ids" eval="[(4, ref('base_action_rule.test_action'))]"/>
</record>

<record id="test_rule_on_line" model="base.action.rule">
<field name="name">Test rule on secondary record</field>
<field name="kind">on_create</field>
<field name="model_id" ref="base_action_rule.model_base_action_rule_line_test"/>
<field name="act_user_id" ref="base.user_demo"/>
</record>

<record id="test_action_context" model="ir.actions.server">
<field name="name">Test Server Action Context</field>
<field name="model_id" ref="base_action_rule.model_base_action_rule_lead_test"/>
<field name="code">
record = model.browse(context['active_id'])
if 'user_id' in context['old_values'][record.id]:
record.write({'is_assigned_to_admin': (record.user_id.id == 1)})
</field>
</record>

<record id="test_rule_on_write_check_context" model="base.action.rule">
<field name="name">Test rule on write check context</field>
<field name="kind">on_write</field>
<field name="model_id" ref="base_action_rule.model_base_action_rule_lead_test"/>
<field name="server_action_ids" eval="[(6, 0, [ref('base_action_rule.test_action_context')])]"/>
</record>
</odoo>
13 changes: 9 additions & 4 deletions addons/base_action_rule/models/base_action_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,18 @@ def _filter_post(self, records):

def _process(self, records):
""" Process action ``self`` on the ``records`` that have not been done yet. """
# filter out the records on which self has already been done, then mark
# remaining records as done (to avoid recursive processing)
# filter out the records on which self has already been done
action_done = self._context['__action_done']
records -= action_done.setdefault(self, records.browse())
records_done = action_done.get(self, records.browse())
records -= records_done
if not records:
return
action_done[self] |= records

# mark the remaining records as done (to avoid recursive processing)
action_done = dict(action_done)
action_done[self] = records_done + records
self = self.with_context(__action_done=action_done)
records = records.with_context(__action_done=action_done)

# modify records
values = {}
Expand Down
24 changes: 24 additions & 0 deletions addons/base_action_rule/tests/test_base_action_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,30 @@ def test_10_recomputed_field(self):
self.assertTrue(lead.customer, "Customer field should updated to True")
self.assertEqual(lead.user_id, self.user_demo, "Responsible should be change on write of Lead when Customer becomes True.")

def test_11_recomputed_field(self):
"""
Check that a rule is executed whenever a field is recomputed and the
context contains the target field
"""
partner = self.env.ref('base.res_partner_1')
lead = self.create_lead(state='draft', partner_id=partner.id)
self.assertFalse(lead.deadline, 'There should not be a deadline defined')
# change priority and user; this triggers deadline recomputation, and
# the server action should set the boolean field to True
lead.write({'priority': True, 'user_id': self.user_admin.id})
self.assertTrue(lead.deadline, 'Deadline should be defined')
self.assertTrue(lead.is_assigned_to_admin, 'Lead should be assigned to admin')

def test_12_recursive(self):
""" Check that a rule is executed recursively by a secondary change. """
lead = self.create_lead(state='open')
self.assertEqual(lead.state, 'open')
self.assertEqual(lead.user_id, self.user_admin)
# change partner; this should trigger the rule that modifies the state
partner = self.env.ref('base.res_partner_1')
lead.write({'partner_id': partner.id})
self.assertEqual(lead.state, 'draft')

def test_20_direct_line(self):
"""
Check that a rule is executed after creating a line record.
Expand Down
14 changes: 13 additions & 1 deletion addons/base_action_rule/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models
from dateutil import relativedelta
from odoo import fields, models, api


class LeadTest(models.Model):
Expand All @@ -19,6 +20,17 @@ class LeadTest(models.Model):
customer = fields.Boolean(related='partner_id.customer', readonly=True, store=True)
line_ids = fields.One2many('base.action.rule.line.test', 'lead_id')

priority = fields.Boolean()
deadline = fields.Boolean(compute='_compute_deadline', store=True)
is_assigned_to_admin = fields.Boolean(string='Assigned to admin user')

@api.depends('priority')
def _compute_deadline(self):
for record in self:
if not record.priority:
record.deadline = False
else:
record.deadline = fields.Datetime.from_string(record.create_date) + relativedelta.relativedelta(days=3)

class LineTest(models.Model):
_name = "base.action.rule.line.test"
Expand Down
2 changes: 1 addition & 1 deletion addons/hr_expense/models/hr_expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _move_line_get(self):
# Calculate tax lines and adjust base line
taxes = expense.tax_ids.compute_all(expense.unit_amount, expense.currency_id, expense.quantity, expense.product_id)
account_move[-1]['price'] = taxes['total_excluded']
account_move[-1]['tax_ids'] = expense.tax_ids.ids
account_move[-1]['tax_ids'] = [(6, 0, expense.tax_ids.ids)]
for tax in taxes['taxes']:
account_move.append({
'type': 'tax',
Expand Down
5 changes: 4 additions & 1 deletion addons/hw_posbox_homepage/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
If you need to grant remote debugging access to a developer, you can do it <a href='/remote_connect'>here</a>.
</p>
<p>
The PosBox software installed on this posbox is <b>version 15</b>,
If you need to display the current customer basket on another device, you can do it <a href='/point_of_sale/display'>here</a>.
</p>
<p>
The PosBox software installed on this posbox is <b>version 16</b>,
the posbox version number is independent from Odoo. You can upgrade
the software on the <a href='/hw_proxy/upgrade/'>upgrade page</a>.
</p>
Expand Down
4 changes: 4 additions & 0 deletions addons/hw_screen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import controllers
21 changes: 21 additions & 0 deletions addons/hw_screen/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Screen Driver',
'version': '1.0',
'category': 'Hardware Drivers',
'sequence': 6,
'summary': 'Provides support for customer facing displays',
'website': 'https://www.odoo.com/page/point-of-sale',
'description': """
Screen Driver
=============
This module allows the POS client to send rendered HTML to a remotely
installed screen. This module then displays this HTML using a web
browser.
""",
'depends': ['hw_proxy'],
'installable': False,
'auto_install': False,
}
4 changes: 4 additions & 0 deletions addons/hw_screen/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import main
Loading

0 comments on commit 2749673

Please sign in to comment.