[MERGE] forward port branch saas-16 up to db0810dc6e

This commit is contained in:
Christophe Simonis
2017-08-23 18:20:46 +02:00
6 changed files with 42 additions and 24 deletions
+28 -18
View File
@@ -982,26 +982,10 @@ class AccountMoveLine(models.Model):
vals['amount_currency'] = sign * abs(sum([r.amount_residual_currency for r in self]))
# Writeoff line in the account of self
first_line_dict = vals.copy()
first_line_dict['account_id'] = self[0].account_id.id
if 'analytic_account_id' in first_line_dict:
del first_line_dict['analytic_account_id']
if 'tax_ids' in first_line_dict:
tax_ids = []
#vals['tax_ids'] is a list of commands [[4, tax_id, None], ...]
for tax_id in vals['tax_ids']:
tax_ids.append(tax_id[1])
amount = first_line_dict['credit'] - first_line_dict['debit']
amount_tax = self.env['account.tax'].browse(tax_ids).compute_all(amount)['total_included']
first_line_dict['credit'] = amount_tax > 0 and amount_tax or 0.0
first_line_dict['debit'] = amount_tax < 0 and abs(amount_tax) or 0.0
del first_line_dict['tax_ids']
first_line_dict = self._prepare_writeoff_first_line_values(vals)
# Writeoff line in specified writeoff account
second_line_dict = vals.copy()
second_line_dict['debit'], second_line_dict['credit'] = second_line_dict['credit'], second_line_dict['debit']
if 'amount_currency' in vals:
second_line_dict['amount_currency'] = -second_line_dict['amount_currency']
second_line_dict = self._prepare_writeoff_second_line_values(vals)
# Create the move
writeoff_move = self.env['account.move'].with_context(apply_taxes=True).create({
@@ -1015,6 +999,32 @@ class AccountMoveLine(models.Model):
# Return the writeoff move.line which is to be reconciled
return writeoff_move.line_ids.filtered(lambda r: r.account_id == self[0].account_id)
@api.multi
def _prepare_writeoff_first_line_values(self, values):
line_values = values.copy()
line_values['account_id'] = self[0].account_id.id
if 'analytic_account_id' in line_values:
del line_values['analytic_account_id']
if 'tax_ids' in line_values:
tax_ids = []
# vals['tax_ids'] is a list of commands [[4, tax_id, None], ...]
for tax_id in values['tax_ids']:
tax_ids.append(tax_id[1])
amount = line_values['credit'] - line_values['debit']
amount_tax = self.env['account.tax'].browse(tax_ids).compute_all(amount)['total_included']
line_values['credit'] = amount_tax > 0 and amount_tax or 0.0
line_values['debit'] = amount_tax < 0 and abs(amount_tax) or 0.0
del line_values['tax_ids']
return line_values
@api.multi
def _prepare_writeoff_second_line_values(self, values):
line_values = values.copy()
line_values['debit'], line_values['credit'] = line_values['credit'], line_values['debit']
if 'amount_currency' in values:
line_values['amount_currency'] = -line_values['amount_currency']
return line_values
@api.model
def compute_full_after_batch_reconcile(self):
""" After running the manual reconciliation wizard and making full reconciliation, we need to run this method to create
+1 -1
View File
@@ -14,7 +14,7 @@ from werkzeug import urls, utils
from odoo import models, fields, api, _
from odoo.tools import ustr
URL_REGEX = r'(\bhref=[\'"](?!mailto:)([^\'"]+)[\'"])'
URL_REGEX = r'(\bhref=[\'"](?!mailto:|tel:|sms:)([^\'"]+)[\'"])'
def VALIDATE_URL(url):
if urls.url_parse(url).scheme not in ('http', 'https', 'ftp', 'ftps'):
@@ -23,6 +23,7 @@
<field name="model">product.product</field>
<field name="priority">4</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="groups_id" eval="[(4, ref('mrp.group_mrp_user'))]"/>
<field name="arch" type="xml">
<div name="standard_price_uom" position="after">
<button name="compute_price"
+2 -4
View File
@@ -187,9 +187,7 @@ class Product(models.Model):
def _website_price(self):
qty = self._context.get('quantity', 1.0)
partner = self.env.user.partner_id
current_website = self.env['website'].get_current_website()
pricelist = current_website.get_current_pricelist()
company_id = current_website.company_id
pricelist = self.env['website'].get_current_website().get_current_pricelist()
context = dict(self._context, pricelist=pricelist.id, partner=partner)
self2 = self.with_context(context) if self._context != context else self
@@ -197,7 +195,7 @@ class Product(models.Model):
ret = self.env.user.has_group('sale.group_show_price_subtotal') and 'total_excluded' or 'total_included'
for p, p2 in pycompat.izip(self, self2):
taxes = partner.property_account_position_id.map_tax(p.taxes_id.filtered(lambda x: x.company_id == company_id))
taxes = partner.property_account_position_id.map_tax(p.taxes_id)
p.website_price = taxes.compute_all(p2.price, pricelist.currency_id, quantity=qty, product=p2, partner=partner)[ret]
p.website_public_price = taxes.compute_all(p2.lst_price, quantity=qty, product=p2, partner=partner)[ret]
@@ -89,7 +89,7 @@ class WebsiteConfigSettings(models.TransientModel):
sale_show_tax = fields.Selection([
('total', 'Tax-Included Prices'),
('subtotal', 'Tax-Excluded Prices')],
"Product Prices", default='total')
"Product Prices", default='subtotal')
@api.model
def get_values(self):
+9
View File
@@ -0,0 +1,9 @@
Tunisia, 2017-08-22
I hereby agree to the terms of the Odoo Individual Contributor License Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this declaration.
Signed,
Borni Dhifi dhifi.borni@gmail.com https://github.com/borni-dhifi