Skip to content

Commit

Permalink
Merge pull request OCA#23 from damdam-s/R_10.0.4
Browse files Browse the repository at this point in the history
R 10.0.4
  • Loading branch information
damdam-s authored Feb 16, 2017
2 parents f321d95 + 9915f64 commit c5ba742
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 27 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ latest (unreleased)
**Features and Improvements**

* Add product options on SO
* Configure margin on SO

**Bugfixes**

Expand Down
2 changes: 2 additions & 0 deletions odoo/data/upgrade/10_0_4/base.action.rule.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,active,model_id/id,sequence,name,kind,filter_pre_id/id,filter_id/id,server_action_ids/id,filter_pre_domain,filter_domain
__setup__.bar_crm_lead_3_arrival,True,crm.model_crm_lead,1,"cannot go to collect information state",on_write,__setup__.filter_crm_lead_1_2,__setup__.filter_crm_lead_3,"__setup__.server_action_crm_lead_check_3_arrival","['|',('stage_id.name', 'ilike', '1'), ('stage_id.name', 'ilike', '2')]","[('stage_id.name', 'ilike', '3')]"
23 changes: 23 additions & 0 deletions odoo/data/upgrade/10_0_4/ir.actions.server.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
id,name,state,type,model_id/id,condition,sequence,code
__setup__.server_action_crm_lead_check_3_arrival,check fields,code,ir.actions.server,crm.model_crm_lead,True,1,"# Available variables:
# - time, datetime, dateutil, timezone: Python libraries
# - env: Odoo Environement
# - model: Model of the record on which the action is triggered
# - record: Record on which the action is triggered if there is one, otherwise None
# - records: Records on which the action is triggered if there is one, otherwise None
# - log : log(message), function to log debug information in logging table
# - Warning: Warning Exception to use with raise
# To return an action, assign: action = {...}

fields = ['project_id', 'start_date', 'end_date', 'signature_ids']
record.check_fields(fields=fields)
"
__setup__.server_action_crm_lead_check_4_arrival,check fields,code,ir.actions.server,crm.model_crm_lead,True,1,"
fields = ['survey_id', 'survey_inputs']
record.check_fields(fields=fields)

record.check_survey_state()
"
__setup__.server_action_crm_lead_check_4_arrival2,create task,code,ir.actions.server,crm.model_crm_lead,True,5,"
record.create_linked_task()
"
4 changes: 4 additions & 0 deletions odoo/data/upgrade/10_0_4/ir.filters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,active,domain,name,model_id
__setup__.filter_crm_lead_1_2,True,"['|',('stage_id.name', 'ilike', '1'), ('stage_id.name', 'ilike', '2')]",Demand |NDA,crm.lead
__setup__.filter_crm_lead_3,True,"[('stage_id.name', 'ilike', '3')]",Lead TRF,crm.lead
__setup__.filter_crm_lead_4,True,"[('stage_id.name', 'ilike', '4')]",Lead Feasability,crm.lead
4 changes: 3 additions & 1 deletion odoo/local-src/specific_crm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"website": "http://www.camptocamp.com",
"license": "GPL-3 or any later version",
"category": "CRM",
"data": ['data/ir_sequence.xml',
"data": ['security/ir.model.access.csv',
'data/ir_sequence.xml',
'views/crm_lead_view.xml',
'views/survey_templates.xml',
'views/crm_team.xml',
'views/project_task.xml',
],
'installable': True,
}
1 change: 1 addition & 0 deletions odoo/local-src/specific_crm/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
from . import crm_lead
from . import survey
from . import crm_team
from . import project_task
24 changes: 24 additions & 0 deletions odoo/local-src/specific_crm/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
# Author: Damien Crier
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import uuid
from datetime import datetime, timedelta

from odoo import models, fields, api
from odoo import exceptions, _


class CrmLead(models.Model):
Expand Down Expand Up @@ -90,3 +92,25 @@ def answer_selected_survey(self):
# 'target': 'new',
'url': url,
}

def check_fields(self, fields=None):
msg = []
if fields:
for f in fields:
if not self[f]:
msg.append(('%s not filled.') % f)

if msg:
raise exceptions.Warning('\n'.join(msg))

def check_survey_state(self):
for s_input in self.survey_inputs:
if s_input.state == 'done':
return True

raise exceptions.Warning(_('Survey not completly answered'))

def create_linked_task(self):
self.env['project.task'].create({'project_id': self.project_id.id,
'lead_id': self.id,
'name': self.name})
14 changes: 14 additions & 0 deletions odoo/local-src/specific_crm/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Author: Damien Crier
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, fields


class ProjectTask(models.Model):
_inherit = 'project.task'

lead_id = fields.Many2one(comodel_name='crm.lead',
string="Linked Opportunity")
survey_input_lines = fields.One2many(related='lead_id.survey_input_lines')
21 changes: 21 additions & 0 deletions odoo/local-src/specific_crm/views/project_task.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_task_form2_lead" model="ir.ui.view">
<field name="name">project.task.form lead</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='project_id']" position="after">
<field name="lead_id"/>
</xpath>
<xpath expr="//notebook" position="inside">
<page string="Survey Result" name="lead_survey" attrs="{'invisible': [('lead_id', '=', False)]}">
<field name="survey_input_lines"/>
</page>
</xpath>
</field>
</record>

</odoo>
2 changes: 1 addition & 1 deletion odoo/local-src/specific_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "RocTool specific sale module",
"version": "10.0.1.0.0",
"depends": ['specific_crm', 'sale', 'sale_crm'],
"depends": ['specific_crm', 'sale', 'sale_crm', 'website_sale_options'],
"author": "Camptocamp,Odoo Community Association (OCA)",
"website": "http://www.camptocamp.com",
"license": "GPL-3 or any later version",
Expand Down
39 changes: 20 additions & 19 deletions odoo/local-src/specific_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,27 @@ def onchange_opportunity_id(self):
'project_market_id': self.opportunity_id.project_market_id.id,
})

@api.onchange('order_line')
@api.onchange('order_line', 'order_line.product_id')
def onchange_order_line(self):
order_line = self.order_line
option_lines = []
for line in order_line:
if line.product_id:
for product in line.product_id.optional_product_ids:
if self.pricelist_id:
price = self.pricelist_id.with_context(
uom=product.uom_id.id).get_product_price(
product, 1, False)
else:
price = product.list_price
data = {
'product_id': product.id,
'name': product.name,
'quantity': 1,
'uom_id': product.uom_id.id,
'price_unit': price,
'discount': 0,
}
option_lines.append((0, 0, data))
if order_line:
for line in order_line:
if line.product_id:
for product in line.product_id.optional_product_ids:
if self.pricelist_id:
price = self.pricelist_id.with_context(
uom=product.uom_id.id).get_product_price(
product, 1, False)
else:
price = product.list_price
data = {
'product_id': product.id,
'name': product.name,
'quantity': 1,
'uom_id': product.uom_id.id,
'price_unit': price,
'discount': 0,
}
option_lines.append((0, 0, data))
self.options = option_lines
3 changes: 3 additions & 0 deletions odoo/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ migration:
operations:
pre:
- anthem songs.install.multi_company::import_companies
- anthem songs.install.sale::configure_sale_app
post:
- anthem songs.install.crm::import_project_zone
- anthem songs.install.crm::import_project_process
Expand All @@ -73,6 +74,7 @@ migration:
- anthem songs.install.crm::import_crm_stages
- anthem songs.install.crm::create_sales_team
- anthem songs.install.crm::add_stage_to_sale_team
- anthem songs.upgrade.10_0_4.crm::main
addons:
upgrade:
- specific_crm
Expand All @@ -81,3 +83,4 @@ migration:
- l10n_us
- l10n_de_skr03
- website_sale
- website_sale_options
7 changes: 2 additions & 5 deletions odoo/songs/install/roctool_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
'base.main_company': 'l10n_fr.l10n_fr_pcg_chart_template',
'__setup__.roctool_inc': 'l10n_generic_coa.configurable_chart_template',
'__setup__.roctool_gmbh': 'l10n_de_skr03.l10n_de_chart_template',
# '__setup__.roctool_taiwan': l10n_cn,
# '__setup__.roctool_japan': 'l10n_jp.l10n_jp1',
# cannot import Japan now because of this bug:
# https://github.com/odoo/odoo/issues/15384
# OPW reported on 2017-02-07
# '__setup__.roctool_taiwan': 'l10n_jp.l10n_jp1',
'__setup__.roctool_japan': 'l10n_jp.l10n_jp1',
}

crm_stages = [
Expand Down
1 change: 1 addition & 0 deletions odoo/songs/install/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def configure_sale_app(ctx):
'group_product_pricelist': False,
'group_sale_pricelist': True,
'group_pricelist_item': True,
'module_sale_margin': 1,
}
acs = sale_settings.create(vals)

Expand Down
Empty file.
79 changes: 79 additions & 0 deletions odoo/songs/upgrade/10_0_4/crm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from pkg_resources import resource_stream

import anthem
from anthem.lyrics.records import create_or_update
from anthem.lyrics.loaders import load_csv_stream
from ...common import req


@anthem.log
def import_filters(ctx):
content = resource_stream(req, 'data/upgrade/10_0_4/ir.filters.csv')
load_csv_stream(ctx, 'ir.filters', content, delimiter=',')


@anthem.log
def import_server_actions(ctx):
content = resource_stream(req, 'data/upgrade/10_0_4/ir.actions.server.csv')
load_csv_stream(ctx, 'ir.actions.server', content, delimiter=',')


@anthem.log
def import_action_rule(ctx):
content = resource_stream(req, 'data/upgrade/10_0_4/base.action.rule.csv')
load_csv_stream(ctx, 'base.action.rule', content, delimiter=',')


@anthem.log
def create_base_action_rules(ctx):
lead_model = ctx.env['ir.model'].search([('model', '=', 'crm.lead')],
limit=1)
bar = {
'__setup__.bar_crm_lead_3_arrival': {
'active': True,
'model_id': lead_model.id,
'sequence': 1,
'name': 'cannot go to collect information state',
'kind': 'on_write',
'filter_pre_id': ctx.env.ref('__setup__.filter_crm_lead_1_2').id,
'filter_pre_domain': "['|',('stage_id.name', 'ilike', '1'),"
"('stage_id.name', 'ilike', '2')]",
'filter_id': ctx.env.ref('__setup__.filter_crm_lead_3').id,
'filter_domain': "[('stage_id.name', 'ilike', '3')]",
'server_action_ids': [
(4, ctx.env.ref(
'__setup__.server_action_crm_lead_check_3_arrival').id)],
},
'__setup__.bar_crm_lead_4_arrival': {
'active': True,
'model_id': lead_model.id,
'sequence': 1,
'name': 'cannot go to feasability state',
'kind': 'on_write',
'filter_pre_id': ctx.env.ref('__setup__.filter_crm_lead_3').id,
'filter_pre_domain': "[('stage_id.name', 'ilike', '3')]",
'filter_id': ctx.env.ref('__setup__.filter_crm_lead_4').id,
'filter_domain': "[('stage_id.name', 'ilike', '4')]",
'server_action_ids': [
(4, ctx.env.ref(
'__setup__.server_action_crm_lead_check_4_arrival').id),
(4, ctx.env.ref(
'__setup__.server_action_crm_lead_check_4_arrival2').id)],
}
}

for k, v in bar.iteritems():
create_or_update(ctx, 'base.action.rule', k, v)


@anthem.log
def main(ctx):
""" Main: creating demo data """
import_filters(ctx)
import_server_actions(ctx)
# import_action_rule(ctx)
create_base_action_rules(ctx)
Empty file added odoo/songs/upgrade/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion odoo/src
Submodule src updated 1231 files

0 comments on commit c5ba742

Please sign in to comment.