Skip to content

Commit

Permalink
[MERGE] forward port of branch 8.0 up to e883193
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Oct 1, 2014
2 parents 85f2624 + e883193 commit 709c986
Show file tree
Hide file tree
Showing 733 changed files with 84,336 additions and 16,080 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you are a developer type the following command at your terminal:

wget -O- https://raw.githubusercontent.com/odoo/odoo/master/odoo.py | python

Then follow <a href="https://doc.openerp.com/trunk/server/howto/howto_website/">the developer tutorial</a>
Then follow <a href="https://doc.odoo.com/trunk/server/howto/howto_website/">the developer tutorial</a>



Expand All @@ -33,11 +33,13 @@ Packages, tarballs and installers
$ sudo apt-get update
$ sudo apt-get install odoo

* <a href="http://nightly.odoo.com/">Source tarballs</a>
If you plan to use Odoo with a local database, please make sure to install PostgreSQL *before* installing the Odoo Debian package.

* <a href="http://nightly.odoo.com/">Windows installer</a>
* <a href="http://nightly.odoo.com/master/nightly/src/">Source tarballs</a>

* <a href="http://nightly.odoo.com/">RPM package</a>
* <a href="http://nightly.odoo.com/master/nightly/exe/">Windows installer</a>

* <a href="http://nightly.odoo.com/master/nightly/rpm/">RPM package</a>


For Odoo employees
Expand Down
6 changes: 3 additions & 3 deletions addons/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ def _check_same_partner(self, cr, uid, ids, context=None):
return True

_constraints = [
(_check_same_partner, 'You can only reconcile journal items with the same partner.', ['line_id']),
(_check_same_partner, 'You can only reconcile journal items with the same partner.', ['line_id', 'line_partial_ids']),
]

def reconcile_partial_check(self, cr, uid, ids, type='auto', context=None):
Expand Down Expand Up @@ -3405,9 +3405,9 @@ def execute(self, cr, uid, ids, context=None):

# write values of default taxes for product as super user
if obj_wizard.sale_tax and taxes_ref:
ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.product', "taxes_id", [taxes_ref[obj_wizard.sale_tax.id]], for_all_users=True, company_id=company_id)
ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.template', "taxes_id", [taxes_ref[obj_wizard.sale_tax.id]], for_all_users=True, company_id=company_id)
if obj_wizard.purchase_tax and taxes_ref:
ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.product', "supplier_taxes_id", [taxes_ref[obj_wizard.purchase_tax.id]], for_all_users=True, company_id=company_id)
ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.template', "supplier_taxes_id", [taxes_ref[obj_wizard.purchase_tax.id]], for_all_users=True, company_id=company_id)

# Create Bank journals
self._create_bank_journals_from_o2m(cr, uid, obj_wizard, company_id, acc_template_ref, context=context)
Expand Down
71 changes: 49 additions & 22 deletions addons/account/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ def link_bank_to_partner(self, cr, uid, ids, context=None):

class account_bank_statement_line(osv.osv):

def create(self, cr, uid, vals, context=None):
if vals.get('amount_currency', 0) and not vals.get('amount', 0):
raise osv.except_osv(_('Error!'), _('If "Amount Currency" is specified, then "Amount" must be as well.'))
return super(account_bank_statement_line, self).create(cr, uid, vals, context=context)

def unlink(self, cr, uid, ids, context=None):
for item in self.browse(cr, uid, ids, context=context):
if item.journal_entry_id:
Expand Down Expand Up @@ -496,6 +501,7 @@ def get_statement_line_for_reconciliation(self, cr, uid, st_line, context=None):
'account_code': st_line.journal_id.default_debit_account_id.code,
'account_name': st_line.journal_id.default_debit_account_id.name,
'partner_name': st_line.partner_id.name,
'communication_partner_name': st_line.partner_name,
'amount_currency_str': amount_currency_str, # Amount in the statement currency
'has_no_partner': not st_line.partner_id.id,
}
Expand Down Expand Up @@ -538,15 +544,20 @@ def get_reconciliation_proposition(self, cr, uid, st_line, excluded_ids=None, co
sign = 1
if statement_currency == company_currency:
amount_field = 'credit'
sign = -1
if st_line.amount > 0:
amount_field = 'debit'
else:
sign = -1
else:
amount_field = 'amount_currency'
if st_line.amount < 0:
sign = -1
if st_line.amount_currency:
amount = st_line.amount_currency
else:
amount = st_line.amount

match_id = self.get_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, offset=0, limit=1, additional_domain=[(amount_field, '=', (sign * st_line.amount))])
match_id = self.get_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, offset=0, limit=1, additional_domain=[(amount_field, '=', (sign * amount))])
if match_id:
return [match_id[0]]

Expand Down Expand Up @@ -576,36 +587,47 @@ def get_move_lines_for_reconciliation(self, cr, uid, st_line, excluded_ids=None,
mv_line_pool = self.pool.get('account.move.line')

# Make domain
domain = additional_domain + [('reconcile_id', '=', False),('state', '=', 'valid')]
domain = additional_domain + [('reconcile_id', '=', False), ('state', '=', 'valid'), ('account_id.reconcile', '=', True)]
if st_line.partner_id.id:
domain += [('partner_id', '=', st_line.partner_id.id),
'|', ('account_id.type', '=', 'receivable'),
('account_id.type', '=', 'payable')]
else:
domain += [('account_id.reconcile', '=', True), ('account_id.type', '=', 'other')]
if str:
domain += [('partner_id.name', 'ilike', str)]
domain += [('partner_id', '=', st_line.partner_id.id)]
if excluded_ids:
domain.append(('id', 'not in', excluded_ids))
if str:
domain += ['|', ('move_id.name', 'ilike', str), ('move_id.ref', 'ilike', str)]

# Get move lines
line_ids = mv_line_pool.search(cr, uid, domain, offset=offset, limit=limit, order="date_maturity asc, id asc", context=context)
lines = mv_line_pool.browse(cr, uid, line_ids, context=context)

# Either return number of lines
if count:
nb_lines = 0
reconcile_partial_ids = [] # for a partial reconciliation, take only one line
if not st_line.partner_id.id:
domain.insert(-1, '|', )
domain.append(('partner_id.name', 'ilike', str))
if str != '/':
domain.insert(-1, '|', )
domain.append(('name', 'ilike', str))

# Get move lines ; in case of a partial reconciliation, only consider one line
filtered_lines = []
reconcile_partial_ids = []
actual_offset = offset
while True:
line_ids = mv_line_pool.search(cr, uid, domain, offset=actual_offset, limit=limit, order="date_maturity asc, id asc", context=context)
lines = mv_line_pool.browse(cr, uid, line_ids, context=context)
make_one_more_loop = False
for line in lines:
if line.reconcile_partial_id and line.reconcile_partial_id.id in reconcile_partial_ids:
#if we filtered a line because it is partially reconciled with an already selected line, we must do one more loop
#in order to get the right number of items in the pager
make_one_more_loop = True
continue
nb_lines += 1
filtered_lines.append(line)
if line.reconcile_partial_id:
reconcile_partial_ids.append(line.reconcile_partial_id.id)
return nb_lines


if not limit or not make_one_more_loop or len(filtered_lines) >= limit:
break
actual_offset = actual_offset + limit
lines = limit and filtered_lines[:limit] or filtered_lines

# Either return number of lines
if count:
return len(lines)

# Or return list of dicts representing the formatted move lines
else:
target_currency = st_line.currency_id or st_line.journal_id.currency or st_line.journal_id.company_id.currency_id
Expand Down Expand Up @@ -639,6 +661,10 @@ def get_currency_rate_line(self, cr, uid, st_line, currency_diff, move_id, conte
'account_id': account_id
}

def process_reconciliations(self, cr, uid, data, context=None):
for datum in data:
self.process_reconciliation(cr, uid, datum[0], datum[1], context=context)

def process_reconciliation(self, cr, uid, id, mv_line_dicts, context=None):
""" Creates a move line for each item of mv_line_dicts and for the statement line. Reconcile a new move line with its counterpart_move_line_id if specified. Finally, mark the statement line as reconciled by putting the newly created move id in the column journal_entry_id.
Expand Down Expand Up @@ -699,6 +725,7 @@ def process_reconciliation(self, cr, uid, id, mv_line_dicts, context=None):
mv_line_dict['statement_id'] = st_line.statement_id.id
if mv_line_dict.get('counterpart_move_line_id'):
mv_line = aml_obj.browse(cr, uid, mv_line_dict['counterpart_move_line_id'], context=context)
mv_line_dict['partner_id'] = mv_line.partner_id.id or st_line.partner_id.id
mv_line_dict['account_id'] = mv_line.account_id.id
if st_line_currency.id != company_currency.id:
ctx = context.copy()
Expand Down
4 changes: 2 additions & 2 deletions addons/account/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _compute_move_lines(self):
elif data_line.reconcile_partial_id:
lines = data_line.reconcile_partial_id.line_partial_ids
else:
lines = self.env['account_move_line']
lines = self.env['account.move.line']
partial_lines += data_line
self.move_lines = lines - partial_lines

Expand Down Expand Up @@ -449,7 +449,7 @@ def onchange_partner_id(self, type, partner_id, date_invoice=False,
account_id = pay_account.id
payment_term_id = p.property_supplier_payment_term.id
fiscal_position = p.property_account_position.id
bank_id = p.bank_ids.id
bank_id = p.bank_ids and p.bank_ids[0].id or False

result = {'value': {
'account_id': account_id,
Expand Down
10 changes: 5 additions & 5 deletions addons/account/account_invoice_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@
</header>
<sheet string="Invoice">
<h1>
<label string="Draft Invoice " attrs="{'invisible': ['|',('state','not in',('draft',)), ('type','&lt;&gt;','out_invoice')]}"/>
<label string="Draft Refund " attrs="{'invisible': ['|',('state','not in',('draft',)), ('type','&lt;&gt;','out_refund')]}"/>
<label string="Pro Forma Invoice " attrs="{'invisible': [('state','not in',('proforma','proforma2'))]}"/>
<label string="Invoice " attrs="{'invisible': ['|',('state','in',('draft','proforma','proforma2')), ('type','&lt;&gt;','out_invoice')]}"/>
<label string="Refund " attrs="{'invisible': ['|',('state','in',('draft','proforma','proforma2')), ('type','&lt;&gt;','out_refund')]}"/>
<label string="Draft Invoice" attrs="{'invisible': ['|',('state','not in',('draft',)), ('type','&lt;&gt;','out_invoice')]}"/>
<label string="Draft Refund" attrs="{'invisible': ['|',('state','not in',('draft',)), ('type','&lt;&gt;','out_refund')]}"/>
<label string="Pro Forma Invoice" attrs="{'invisible': [('state','not in',('proforma','proforma2'))]}"/>
<label string="Invoice" attrs="{'invisible': ['|',('state','in',('draft','proforma','proforma2')), ('type','&lt;&gt;','out_invoice')]}"/>
<label string="Refund" attrs="{'invisible': ['|',('state','in',('draft','proforma','proforma2')), ('type','&lt;&gt;','out_refund')]}"/>
<field name="number" readonly="1" class="oe_inline"/>
</h1>
<field name="type" invisible="1"/>
Expand Down
49 changes: 36 additions & 13 deletions addons/account/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,18 +766,17 @@ def prepare_move_lines_for_reconciliation_widget(self, cr, uid, lines, target_cu
currency_obj = self.pool.get('res.currency')
company_currency = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id
rml_parser = report_sxw.rml_parse(cr, uid, 'reconciliation_widget_aml', context=context)
reconcile_partial_ids = [] # for a partial reconciliation, take only one line
ret = []

for line in lines:
if line.reconcile_partial_id and line.reconcile_partial_id.id in reconcile_partial_ids:
continue
partial_reconciliation_siblings_ids = []
if line.reconcile_partial_id:
reconcile_partial_ids.append(line.reconcile_partial_id.id)
partial_reconciliation_siblings_ids = self.search(cr, uid, [('reconcile_partial_id', '=', line.reconcile_partial_id.id)], context=context)
partial_reconciliation_siblings_ids.remove(line.id)

ret_line = {
'id': line.id,
'name': line.move_id.name,
'name': line.name != '/' and line.move_id.name + ': ' + line.name or line.move_id.name,
'ref': line.move_id.ref,
'account_code': line.account_id.code,
'account_name': line.account_id.name,
Expand All @@ -788,35 +787,59 @@ def prepare_move_lines_for_reconciliation_widget(self, cr, uid, lines, target_cu
'journal_name': line.journal_id.name,
'partner_id': line.partner_id.id,
'partner_name': line.partner_id.name,
'is_partially_reconciled': bool(line.reconcile_partial_id),
'partial_reconciliation_siblings_ids': partial_reconciliation_siblings_ids,
}

# Amount residual can be negative
debit = line.debit
credit = line.credit
total_amount = abs(debit - credit)
total_amount_currency = line.amount_currency
amount_residual = line.amount_residual
amount_residual_currency = line.amount_residual_currency
if line.amount_residual < 0:
debit, credit = credit, debit
amount_residual = -amount_residual
amount_residual_currency = -amount_residual_currency

# Get right debit / credit:
line_currency = line.currency_id or company_currency
amount_currency_str = ""
total_amount_currency_str = ""
if line.currency_id and line.amount_currency:
amount_currency_str = rml_parser.formatLang(line.amount_currency, currency_obj=line.currency_id)
amount_currency_str = rml_parser.formatLang(amount_residual_currency, currency_obj=line.currency_id)
total_amount_currency_str = rml_parser.formatLang(total_amount_currency, currency_obj=line.currency_id)
if target_currency and line_currency == target_currency and target_currency != company_currency:
debit = line.debit > 0 and line.amount_residual_currency or 0.0
credit = line.credit > 0 and line.amount_residual_currency or 0.0
amount_currency_str = rml_parser.formatLang(line.amount_residual, currency_obj=company_currency)
debit = debit > 0 and amount_residual_currency or 0.0
credit = credit > 0 and amount_residual_currency or 0.0
amount_currency_str = rml_parser.formatLang(amount_residual, currency_obj=company_currency)
total_amount_currency_str = rml_parser.formatLang(total_amount, currency_obj=company_currency)
amount_str = rml_parser.formatLang(debit or credit, currency_obj=target_currency)
total_amount_str = rml_parser.formatLang(total_amount_currency, currency_obj=target_currency)
else:
debit = line.debit > 0 and line.amount_residual or 0.0
credit = line.credit > 0 and line.amount_residual or 0.0
debit = debit > 0 and amount_residual or 0.0
credit = credit > 0 and amount_residual or 0.0
amount_str = rml_parser.formatLang(debit or credit, currency_obj=company_currency)
total_amount_str = rml_parser.formatLang(total_amount, currency_obj=company_currency)
if target_currency and target_currency != company_currency:
amount_currency_str = rml_parser.formatLang(debit or credit, currency_obj=line_currency)
total_amount_currency_str = rml_parser.formatLang(total_amount, currency_obj=line_currency)
ctx = context.copy()
if target_date:
ctx.update({'date': target_date})
debit = currency_obj.compute(cr, uid, target_currency.id, company_currency.id, debit, context=ctx)
credit = currency_obj.compute(cr, uid, target_currency.id, company_currency.id, credit, context=ctx)
debit = currency_obj.compute(cr, uid, company_currency.id, target_currency.id, debit, context=ctx)
credit = currency_obj.compute(cr, uid, company_currency.id, target_currency.id, credit, context=ctx)
amount_str = rml_parser.formatLang(debit or credit, currency_obj=target_currency)
total_amount = currency_obj.compute(cr, uid, company_currency.id, target_currency.id, total_amount, context=ctx)
total_amount_str = rml_parser.formatLang(total_amount, currency_obj=target_currency)

ret_line['credit'] = credit
ret_line['debit'] = debit
ret_line['amount_str'] = amount_str
ret_line['amount_currency_str'] = amount_currency_str
ret_line['total_amount_str'] = total_amount_str # For partial reconciliations
ret_line['total_amount_currency_str'] = total_amount_currency_str
ret.append(ret_line)
return ret

Expand Down
Loading

0 comments on commit 709c986

Please sign in to comment.