Skip to content

Commit

Permalink
[MERGE] forward port branch 11.0 up to 0196a6f
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Mar 25, 2019
2 parents 36289e7 + 0196a6f commit e9068c2
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 70 deletions.
13 changes: 9 additions & 4 deletions addons/crm/models/crm_team.py
Expand Up @@ -50,13 +50,18 @@ def _compute_unassigned_leads_count(self):
team.unassigned_leads_count = counts.get(team.id, 0)

def _compute_opportunities(self):
opportunity_data = self.env['crm.lead'].read_group([
opportunity_data = self.env['crm.lead'].search([
('team_id', 'in', self.ids),
('probability', '<', 100),
('type', '=', 'opportunity'),
], ['planned_revenue', 'probability', 'team_id'], ['team_id'])
counts = {datum['team_id'][0]: datum['team_id_count'] for datum in opportunity_data}
amounts = {datum['team_id'][0]: (datum['planned_revenue'] * datum['probability'] / 100) for datum in opportunity_data}
]).read(['planned_revenue', 'probability', 'team_id'])
counts = {}
amounts = {}
for datum in opportunity_data:
counts.setdefault(datum['team_id'][0], 0)
amounts.setdefault(datum['team_id'][0], 0)
counts[datum['team_id'][0]] += 1
amounts[datum['team_id'][0]] += (datum.get('planned_revenue', 0) * datum.get('probability', 0) / 100.0)
for team in self:
team.opportunities_count = counts.get(team.id, 0)
team.opportunities_amount = amounts.get(team.id, 0)
Expand Down
2 changes: 1 addition & 1 deletion addons/fleet/models/fleet_vehicle_cost.py
Expand Up @@ -270,7 +270,7 @@ def scheduler_manage_contract_expiration(self):
'fleet.mail_act_fleet_contract_to_renew', contract.expiration_date,
user_id=contract.user_id.id)

expired_contracts = self.search([('state', '!=', 'expired'), ('expiration_date', '<',fields.Date.today() )])
expired_contracts = self.search([('state', 'not in', ['expired', 'closed']), ('expiration_date', '<',fields.Date.today() )])
expired_contracts.write({'state': 'expired'})

futur_contracts = self.search([('state', 'not in', ['futur', 'closed']), ('start_date', '>', fields.Date.today())])
Expand Down
5 changes: 3 additions & 2 deletions addons/l10n_tr/__manifest__.py
Expand Up @@ -13,9 +13,9 @@
* Sihirbaz sizden hesap planı şablonu, planın kurulacağı şirket, banka hesap
bilgileriniz, ilgili para birimi gibi bilgiler isteyecek.
""",
'author': 'Ahmet Altınışık',
'author': 'Ahmet Altınışık, Can Tecim',
'maintainer':'https://launchpad.net/~openerp-turkey',
'website':'https://launchpad.net/openerp-turkey',
'website':'https://launchpad.net/openerp-turkey, http://www.cantecim.com',
'depends': [
'account',
],
Expand All @@ -24,5 +24,6 @@
'data/account_data.xml',
'data/account_tax_template_data.xml',
'data/account_chart_template_data.xml',
'data/res.country.state.csv'
],
}
82 changes: 82 additions & 0 deletions addons/l10n_tr/data/res.country.state.csv
@@ -0,0 +1,82 @@
"id","country_id:id","name","code"
state_tr_01,base.tr,"Adana","01"
state_tr_02,base.tr,"Adıyaman","02"
state_tr_03,base.tr,"Afyon","03"
state_tr_04,base.tr,"Ağrı","04"
state_tr_05,base.tr,"Amasya","05"
state_tr_06,base.tr,"Ankara","06"
state_tr_07,base.tr,"Antalya","07"
state_tr_08,base.tr,"Artvin","08"
state_tr_09,base.tr,"Aydın","09"
state_tr_10,base.tr,"Balıkesir","10"
state_tr_11,base.tr,"Bilecik","11"
state_tr_12,base.tr,"Bingöl","12"
state_tr_13,base.tr,"Bitlis","13"
state_tr_14,base.tr,"Bolu","14"
state_tr_15,base.tr,"Burdur","15"
state_tr_16,base.tr,"Bursa","16"
state_tr_17,base.tr,"Çanakkale","17"
state_tr_18,base.tr,"Çankırı","18"
state_tr_19,base.tr,"Çorum","19"
state_tr_20,base.tr,"Denizli","20"
state_tr_21,base.tr,"Diyarbakır","21"
state_tr_22,base.tr,"Edirne","22"
state_tr_23,base.tr,"Elazığ","23"
state_tr_24,base.tr,"Erzincan","24"
state_tr_25,base.tr,"Erzurum","25"
state_tr_26,base.tr,"Eskişehir","26"
state_tr_27,base.tr,"Gaziantep","27"
state_tr_28,base.tr,"Giresun","28"
state_tr_29,base.tr,"Gümüşhane","29"
state_tr_30,base.tr,"Hakkari","30"
state_tr_31,base.tr,"Hatay","31"
state_tr_32,base.tr,"Isparta","32"
state_tr_33,base.tr,"İçel","33"
state_tr_34,base.tr,"İstanbul","34"
state_tr_35,base.tr,"İzmir","35"
state_tr_36,base.tr,"Kars","36"
state_tr_37,base.tr,"Kastamonu","37"
state_tr_38,base.tr,"Kayseri","38"
state_tr_39,base.tr,"Kırklareli","39"
state_tr_40,base.tr,"Kırşehir","40"
state_tr_41,base.tr,"Kocaeli","41"
state_tr_42,base.tr,"Konya","42"
state_tr_43,base.tr,"Kütahya","43"
state_tr_44,base.tr,"Malatya","44"
state_tr_45,base.tr,"Manisa","45"
state_tr_46,base.tr,"K.maraş","46"
state_tr_47,base.tr,"Mardin","47"
state_tr_48,base.tr,"Muğla","48"
state_tr_49,base.tr,"Muş","49"
state_tr_50,base.tr,"Nevşehir","50"
state_tr_51,base.tr,"Niğde","51"
state_tr_52,base.tr,"Ordu","52"
state_tr_53,base.tr,"Rize","53"
state_tr_54,base.tr,"Sakarya","54"
state_tr_55,base.tr,"Samsun","55"
state_tr_56,base.tr,"Siirt","56"
state_tr_57,base.tr,"Sinop","57"
state_tr_58,base.tr,"Sivas","58"
state_tr_59,base.tr,"Tekirdağ","59"
state_tr_60,base.tr,"Tokat","60"
state_tr_61,base.tr,"Trabzon","61"
state_tr_62,base.tr,"Tunceli","62"
state_tr_63,base.tr,"Şanlıurfa","63"
state_tr_64,base.tr,"Uşak","64"
state_tr_65,base.tr,"Van","65"
state_tr_66,base.tr,"Yozgat","66"
state_tr_67,base.tr,"Zonguldak","67"
state_tr_68,base.tr,"Aksaray","68"
state_tr_69,base.tr,"Bayburt","69"
state_tr_70,base.tr,"Karaman","70"
state_tr_71,base.tr,"Kırıkkale","71"
state_tr_72,base.tr,"Batman","72"
state_tr_73,base.tr,"Şırnak","73"
state_tr_74,base.tr,"Bartın","74"
state_tr_75,base.tr,"Ardahan","75"
state_tr_76,base.tr,"Iğdır","76"
state_tr_77,base.tr,"Yalova","77"
state_tr_78,base.tr,"Karabük","78"
state_tr_79,base.tr,"Kilis","79"
state_tr_80,base.tr,"Osmaniye","80"
state_tr_81,base.tr,"Düzce","81"
31 changes: 22 additions & 9 deletions addons/mass_mailing/models/mass_mailing.py
Expand Up @@ -668,15 +668,28 @@ def _get_seen_list(self):
"""Returns a set of emails already targeted by current mailing/campaign (no duplicates)"""
self.ensure_one()
target = self.env[self.mailing_model_real]
mail_field = 'email' if 'email' in target._fields else 'email_from'
# avoid loading a large number of records in memory
# + use a basic heuristic for extracting emails
query = """
SELECT lower(substring(%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)'))
FROM mail_mail_statistics s
JOIN %(target)s t ON (s.res_id = t.id)
WHERE substring(%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)') IS NOT NULL
"""
if set(['email', 'email_from']) & set(target._fields):
mail_field = 'email' if 'email' in target._fields else 'email_from'
# avoid loading a large number of records in memory
# + use a basic heuristic for extracting emails
query = """
SELECT lower(substring(%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)'))
FROM mail_mail_statistics s
JOIN %(target)s t ON (s.res_id = t.id)
WHERE substring(%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)') IS NOT NULL
"""
elif 'partner_id' in target._fields:
mail_field = 'email'
query = """
SELECT lower(substring(p.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)'))
FROM mail_mail_statistics s
JOIN %(target)s t ON (s.res_id = t.id)
JOIN res_partner p ON (t.partner_id = p.id)
WHERE substring(p.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)') IS NOT NULL
"""
else:
raise UserError(_("Unsupported mass mailing model %s") % self.mailing_model_id.name)

if self.mass_mailing_campaign_id.unique_ab_testing:
query +="""
AND s.mass_mailing_campaign_id = %%(mailing_campaign_id)s;
Expand Down
2 changes: 1 addition & 1 deletion addons/mrp/models/mrp_workorder.py
Expand Up @@ -246,7 +246,7 @@ def _onchange_qty_producing(self):

@api.multi
def write(self, values):
if ('date_planned_start' in values or 'date_planned_finished' in values) and any(workorder.state == 'done' for workorder in self):
if list(values.keys()) != ['time_ids'] and any(workorder.state == 'done' for workorder in self):
raise UserError(_('You can not change the finished work order.'))
return super(MrpWorkorder, self).write(values)

Expand Down
40 changes: 38 additions & 2 deletions addons/payment_adyen/models/payment.py
Expand Up @@ -18,6 +18,31 @@

_logger = logging.getLogger(__name__)

# https://docs.adyen.com/developers/development-resources/currency-codes
CURRENCY_CODE_MAPS = {
"BHD": 3,
"CVE": 0,
"DJF": 0,
"GNF": 0,
"IDR": 0,
"JOD": 3,
"JPY": 0,
"KMF": 0,
"KRW": 0,
"KWD": 3,
"LYD": 3,
"OMR": 3,
"PYG": 0,
"RWF": 0,
"TND": 3,
"UGX": 0,
"VND": 0,
"VUV": 0,
"XAF": 0,
"XOF": 0,
"XPF": 0,
}


class AcquirerAdyen(models.Model):
_inherit = 'payment.acquirer'
Expand All @@ -27,6 +52,16 @@ class AcquirerAdyen(models.Model):
adyen_skin_code = fields.Char('Skin Code', required_if_provider='adyen', groups='base.group_user')
adyen_skin_hmac_key = fields.Char('Skin HMAC Key', required_if_provider='adyen', groups='base.group_user')

@api.model
def _adyen_convert_amount(self, amount, currency):
"""
Adyen requires the amount to be multiplied by 10^k,
where k depends on the currency code.
"""
k = CURRENCY_CODE_MAPS.get(currency.name, 2)
paymentAmount = int(tools.float_round(amount, k) * (10**k))
return paymentAmount

@api.model
def _get_adyen_urls(self, environment):
""" Adyen URLs: yhpp: hosted payment page: pay.shtml for single, select.shtml for multiple """
Expand Down Expand Up @@ -120,12 +155,13 @@ def adyen_form_generate_values(self, values):
import datetime
from dateutil import relativedelta

paymentAmount = self._adyen_convert_amount(values['amount'], values['currency'])
if self.provider == 'adyen' and len(self.adyen_skin_hmac_key) == 64:
tmp_date = datetime.datetime.today() + relativedelta.relativedelta(days=1)

values.update({
'merchantReference': values['reference'],
'paymentAmount': '%d' % int(tools.float_round(values['amount'], 2) * 100),
'paymentAmount': '%d' % paymentAmount,
'currencyCode': values['currency'] and values['currency'].name or '',
'shipBeforeDate': tmp_date.strftime('%Y-%m-%d'),
'skinCode': self.adyen_skin_code,
Expand All @@ -143,7 +179,7 @@ def adyen_form_generate_values(self, values):

values.update({
'merchantReference': values['reference'],
'paymentAmount': '%d' % int(tools.float_round(values['amount'], 2) * 100),
'paymentAmount': '%d' % paymentAmount,
'currencyCode': values['currency'] and values['currency'].name or '',
'shipBeforeDate': tmp_date,
'skinCode': self.adyen_skin_code,
Expand Down
6 changes: 5 additions & 1 deletion addons/payment_stripe/static/src/js/stripe.js
Expand Up @@ -21,9 +21,13 @@ odoo.define('payment_stripe.stripe', function(require) {
$.blockUI.defaults.css["background-color"] = '';
$.blockUI.defaults.overlayCSS["opacity"] = '0.9';
}
var stripeHandler;
function getStripeHandler()
{
var handler = StripeCheckout.configure({
if (stripeHandler) {
return stripeHandler;
}
var handler = stripeHandler = StripeCheckout.configure({
key: $("input[name='stripe_key']").val(),
image: $("input[name='stripe_image']").val(),
locale: 'auto',
Expand Down
7 changes: 6 additions & 1 deletion addons/payment_stripe/views/payment_stripe_templates.xml
Expand Up @@ -21,7 +21,12 @@
<input type='hidden' name='email' t-att-value='email'/>
<input id="acquirer_stripe" type='hidden' name="acquirer" t-att-value="acquirer.id"/>
<input type='hidden' name="stripe_key" t-att-value="acquirer.stripe_publishable_key"/>
<script type="text/javascript" src="/payment_stripe/static/src/js/stripe.js"></script>
<script type="text/javascript">
odoo.define(function (require) {
var ajax = require('web.ajax');
ajax.loadJS("/payment_stripe/static/src/js/stripe.js");
});
</script>
</template>

<template id="stripe_s2s_form">
Expand Down
2 changes: 1 addition & 1 deletion addons/stock/models/stock_move.py
Expand Up @@ -147,7 +147,7 @@ def _default_group_id(self):
restrict_partner_id = fields.Many2one('res.partner', 'Owner ', help="Technical field used to depict a restriction on the ownership of quants to consider when marking this move as 'done'")
route_ids = fields.Many2many('stock.location.route', 'stock_location_route_move', 'move_id', 'route_id', 'Destination route', help="Preferred route")
warehouse_id = fields.Many2one('stock.warehouse', 'Warehouse', help="Technical field depicting the warehouse to consider for the route selection on the next procurement (if any).")
has_tracking = fields.Selection(related='product_id.tracking', string='Product with Tracking')
has_tracking = fields.Selection(related='product_id.tracking', string='Product with Tracking', readonly=True)
quantity_done = fields.Float('Quantity Done', compute='_quantity_done_compute', digits=dp.get_precision('Product Unit of Measure'), inverse='_quantity_done_set')
show_operations = fields.Boolean(related='picking_id.picking_type_id.show_operations')
show_details_visible = fields.Boolean('Details Visible', compute='_compute_show_details_visible')
Expand Down
2 changes: 1 addition & 1 deletion addons/stock/views/stock_picking_views.xml
Expand Up @@ -353,7 +353,7 @@
<filter name="done" string="Done" domain="[('state','=','done')]" help="Pickings already processed"/>
<filter name="cancel" string="Cancelled" domain="[('state','=', 'cancel')]" help="Cancelled Moves"/>
<separator/>
<filter name="late" string="Late" domain="[('scheduled_date','&lt;', time.strftime('%%Y-%%m-%%d %%H:%%M:%%S'))]" help="Pickings that are late on scheduled time"/>
<filter name="late" string="Late" domain="[('scheduled_date','&lt;', time.strftime('%%Y-%%m-%%d %%H:%%M:%%S')), ('state', 'in', ('assigned', 'waiting', 'confirmed'))]" help="Pickings that are late on scheduled time"/>
<separator/>
<filter name="backorder" string="Backorders" domain="[('backorder_id','!=', False)]" help="Remaining parts of picking partially processed"/>
<separator/>
Expand Down
8 changes: 4 additions & 4 deletions addons/test_mail/tests/test_mail_gateway.py
Expand Up @@ -499,7 +499,7 @@ def test_private_discussion(self):
self.assertEqual(msg.model, False,
'message_post: private discussion: context key "thread_model" not correctly ignored when having no res_id')
# Test: message-id
self.assertIn('openerp-private', msg.message_id, 'message_post: private discussion: message-id should contain the private keyword')
self.assertIn('openerp-private', msg.message_id.split('@')[0], 'message_post: private discussion: message-id should contain the private keyword')

# Do: Bert replies through mailgateway (is a customer)
self.format_and_process(
Expand Down Expand Up @@ -527,9 +527,9 @@ def test_private_discussion(self):
@mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models', 'odoo.addons.mail.models.mail_mail')
def test_forward_parent_id(self):
msg = self.test_record.sudo(self.user_employee).message_post(no_auto_thread=True, subtype='mail.mt_comment')
self.assertNotIn(msg.model, msg.message_id)
self.assertNotIn('-%d-' % msg.res_id, msg.message_id)
self.assertIn('reply_to', msg.message_id)
self.assertNotIn(msg.model, msg.message_id.split('@')[0])
self.assertNotIn('-%d-' % msg.res_id, msg.message_id.split('@')[0])
self.assertIn('reply_to', msg.message_id.split('@')[0])

# forward it to a new thread AND an existing thread
fw_msg_id = '<THIS.IS.A.FW.MESSAGE.1@bert.fr>'
Expand Down

0 comments on commit e9068c2

Please sign in to comment.