[MERGE] forward port branch 9.0 up to 6f29e7307e
This commit is contained in:
@@ -475,7 +475,7 @@ class AccountInvoice(models.Model):
|
||||
account_id = pay_account.id
|
||||
payment_term_id = p.property_supplier_payment_term_id.id
|
||||
fiscal_position = p.property_account_position_id.id
|
||||
bank_id = p.bank_ids and p.bank_ids.ids[0] or False
|
||||
|
||||
|
||||
# If partner has no warning, check its company
|
||||
if p.invoice_warn == 'no-message' and p.parent_id:
|
||||
@@ -496,8 +496,12 @@ class AccountInvoice(models.Model):
|
||||
self.payment_term_id = payment_term_id
|
||||
self.fiscal_position_id = fiscal_position
|
||||
|
||||
if type in ('in_invoice', 'in_refund'):
|
||||
if type in ('in_invoice', 'out_refund'):
|
||||
bank_ids = p.commercial_partner_id.bank_ids
|
||||
bank_id = bank_ids[0].id if bank_ids else False
|
||||
self.partner_bank_id = bank_id
|
||||
return {'domain': {'partner_bank_id': [('id', 'in', bank_ids.ids)]}}
|
||||
return {}
|
||||
|
||||
|
||||
@api.onchange('journal_id')
|
||||
|
||||
@@ -695,22 +695,37 @@ class AccountMoveLine(models.Model):
|
||||
line_currency = (line.currency_id and line.amount_currency) and line.currency_id or company_currency
|
||||
amount_currency_str = ""
|
||||
total_amount_currency_str = ""
|
||||
if line_currency != company_currency and target_currency != company_currency:
|
||||
if line_currency != company_currency and target_currency == line_currency:
|
||||
# The payment currency is the invoice currency, but they are different than the company currency
|
||||
# We use the `amount_currency` computed during the invoice validation, at the invoice date
|
||||
# to avoid exchange gain/loss
|
||||
# e.g. an invoice of 100€ must be paid with 100€, whatever the company currency and the exchange rates
|
||||
total_amount = line.amount_currency
|
||||
actual_debit = debit > 0 and amount_currency or 0.0
|
||||
actual_credit = credit > 0 and -amount_currency or 0.0
|
||||
currency = line_currency
|
||||
else:
|
||||
# Either:
|
||||
# - the invoice, payment, company currencies are all the same,
|
||||
# - the payment currency is the company currency, but the invoice currency is different,
|
||||
# - the invoice currency is the company currency, but the payment currency is different,
|
||||
# - the invoice, payment and company currencies are all different.
|
||||
# For the two first cases, we can simply use the debit/credit of the invoice move line, which are always in the company currency,
|
||||
# and this is what the target need.
|
||||
# For the two last cases, we can use the debit/credit which are in the company currency, and then change them to the target currency
|
||||
total_amount = abs(debit - credit)
|
||||
actual_debit = debit > 0 and amount or 0.0
|
||||
actual_credit = credit > 0 and -amount or 0.0
|
||||
if line_currency != target_currency and target_currency != company_currency:
|
||||
currency = company_currency
|
||||
if line_currency != target_currency:
|
||||
amount_currency_str = formatLang(self.env, abs(actual_debit or actual_credit), currency_obj=line_currency)
|
||||
total_amount_currency_str = formatLang(self.env, total_amount, currency_obj=line_currency)
|
||||
if currency != target_currency:
|
||||
ctx = context.copy()
|
||||
ctx.update({'date': target_date or line.date})
|
||||
total_amount = line_currency.with_context(ctx).compute(total_amount, target_currency)
|
||||
actual_debit = line_currency.with_context(ctx).compute(actual_debit, target_currency)
|
||||
actual_credit = line_currency.with_context(ctx).compute(actual_credit, target_currency)
|
||||
total_amount = currency.with_context(ctx).compute(total_amount, target_currency)
|
||||
actual_debit = currency.with_context(ctx).compute(actual_debit, target_currency)
|
||||
actual_credit = currency.with_context(ctx).compute(actual_credit, target_currency)
|
||||
amount_str = formatLang(self.env, abs(actual_debit or actual_credit), currency_obj=target_currency)
|
||||
total_amount_str = formatLang(self.env, total_amount, currency_obj=target_currency)
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ class account_payment(models.Model):
|
||||
# the writeoff debit and credit must be computed from the invoice residual in company currency
|
||||
# minus the payment amount in company currency, and not from the payment difference in the payment currency
|
||||
# to avoid loss of precision during the currency rate computations. See revision 20935462a0cabeb45480ce70114ff2f4e91eaf79 for a detailed example.
|
||||
total_residual_company_signed = self._compute_total_invoices_amount()
|
||||
total_residual_company_signed = sum(invoice.residual_company_signed for invoice in self.invoice_ids)
|
||||
total_payment_company_signed = self.currency_id.with_context(date=self.payment_date).compute(self.amount, self.company_id.currency_id)
|
||||
if self.invoice_ids[0].type in ['in_invoice', 'out_refund']:
|
||||
amount_wo = total_payment_company_signed - total_residual_company_signed
|
||||
|
||||
@@ -1118,7 +1118,6 @@
|
||||
<field name="move_id" required="False"/>
|
||||
<newline/>
|
||||
<field name="date_maturity"/>
|
||||
<field name="date"/>
|
||||
<field name="blocked"/>
|
||||
<newline/>
|
||||
<field name="tax_ids" readonly="1"/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<data noupdate='1'>
|
||||
<function id="default_generate_sales_team_alias"
|
||||
model="ir.values" name="set_default"
|
||||
eval="('sales.config.settings', 'generate_sales_team_alias', True)"/>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -14,7 +14,7 @@ class res_partner_grade(osv.osv):
|
||||
_columns = {
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'active': fields.boolean('Active'),
|
||||
'name': fields.char('Level Name'),
|
||||
'name': fields.char('Level Name', translate=True),
|
||||
'partner_weight': fields.integer('Level Weight',
|
||||
help="Gives the probability to assign a lead to this partner. (0 means no assignation.)"),
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ class PosOrder(models.Model):
|
||||
|
||||
grouped_data = {}
|
||||
have_to_group_by = session and session.config_id.group_by or False
|
||||
rounding_method = session and session.config_id.company_id.tax_calculation_rounding_method
|
||||
|
||||
for order in self.filtered(lambda o: not o.account_move or order.state == 'paid'):
|
||||
current_company = order.sale_journal.company_id
|
||||
@@ -303,6 +304,14 @@ class PosOrder(models.Model):
|
||||
'partner_id': partner_id
|
||||
})
|
||||
|
||||
# round tax lines per order
|
||||
if rounding_method == 'round_globally':
|
||||
for group_key, group_value in grouped_data.iteritems():
|
||||
if group_key[0] == 'tax':
|
||||
for line in group_value:
|
||||
line['credit'] = cur.round(line['credit'])
|
||||
line['debit'] = cur.round(line['debit'])
|
||||
|
||||
# counterpart
|
||||
insert_data('counter_part', {
|
||||
'name': _("Trade Receivables"), # order.name,
|
||||
|
||||
@@ -336,7 +336,7 @@
|
||||
</div>
|
||||
<div class='client-detail'>
|
||||
<span class='label'>Country</span>
|
||||
<select class='detail client-address-country' name='country_id'>
|
||||
<select class='detail client-address-country needsclick' name='country_id'>
|
||||
<option value=''>None</option>
|
||||
<t t-foreach='widget.pos.countries' t-as='country'>
|
||||
<option t-att-value='country.id' t-att-selected="partner.country_id ? ((country.id === partner.country_id[0]) ? true : undefined) : undefined">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<field name="name">report.pos.order.pivot</field>
|
||||
<field name="model">report.pos.order</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Point of Sale Analysis">
|
||||
<pivot string="Point of Sale Analysis" disable_linking="True">
|
||||
<field name="product_categ_id" type="row"/>
|
||||
<field name="date" interval="month" type="col"/>
|
||||
<field name="product_qty" type="measure"/>
|
||||
|
||||
+1
-1
@@ -2291,7 +2291,7 @@ class BaseModel(object):
|
||||
prefix_term = lambda prefix, term: ('%s %s' % (prefix, term)) if term else ''
|
||||
|
||||
query = """
|
||||
SELECT min(%(table)s.id) AS id, count(%(table)s.id) AS %(count_field)s %(extra_fields)s
|
||||
SELECT min("%(table)s".id) AS id, count("%(table)s".id) AS "%(count_field)s" %(extra_fields)s
|
||||
FROM %(from)s
|
||||
%(where)s
|
||||
%(groupby)s
|
||||
|
||||
Reference in New Issue
Block a user