[MERGE] forward port branch saas-15 up to 0cfbc7581f

This commit is contained in:
Christophe Simonis
2017-08-23 18:15:56 +02:00
8 changed files with 43 additions and 27 deletions
+28 -18
View File
@@ -973,26 +973,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({
@@ -1006,6 +990,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
@@ -15,7 +15,7 @@ from werkzeug import url_encode, unescape
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 urlparse(url).scheme not in ('http', 'https', 'ftp', 'ftps'):
@@ -29,8 +29,6 @@
<field name="quantity_done"/>
<field name="lot_id" context="{'default_product_id': product_id}"/>
<field name="move_id" invisible="1"/>
<button name="do_minus" type="object" icon="fa-minus-square" attrs="{'invisible': [('quantity_done', '&lt;=', 0.99)]}" invisible="context.get('state_done')"/>
<button name="do_plus" type="object" icon="fa-plus-square" attrs="{'invisible': [('plus_visible', '=', False)]}" invisible="context.get('state_done')"/>
</tree>
</field>
</group>
@@ -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"
+1 -1
View File
@@ -90,7 +90,7 @@ class PackOperation(models.Model):
res = self.package_id._get_all_products_quantities()
# reduce by the quantities linked to a move
for record in self.linked_move_operation_ids:
if record.move_id.product_id.id not in res:
if record.move_id.product_id not in res:
res[record.move_id.product_id] = 0
res[record.move_id.product_id] -= record.qty
return res
+2 -4
View File
@@ -190,9 +190,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
@@ -200,7 +198,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 zip(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]
+1 -1
View File
@@ -78,7 +78,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_default_sale_delivery_settings(self, fields):
+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