diff --git a/HISTORY.rst b/HISTORY.rst index 80165cf775d..a737c94935f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -22,6 +22,7 @@ latest (unreleased) **Features and Improvements** * Add product options on SO +* Configure margin on SO **Bugfixes** diff --git a/odoo/data/upgrade/10_0_4/base.action.rule.csv b/odoo/data/upgrade/10_0_4/base.action.rule.csv new file mode 100644 index 00000000000..efe407a595f --- /dev/null +++ b/odoo/data/upgrade/10_0_4/base.action.rule.csv @@ -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')]" diff --git a/odoo/data/upgrade/10_0_4/ir.actions.server.csv b/odoo/data/upgrade/10_0_4/ir.actions.server.csv new file mode 100644 index 00000000000..d69f8848d51 --- /dev/null +++ b/odoo/data/upgrade/10_0_4/ir.actions.server.csv @@ -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() +" \ No newline at end of file diff --git a/odoo/data/upgrade/10_0_4/ir.filters.csv b/odoo/data/upgrade/10_0_4/ir.filters.csv new file mode 100644 index 00000000000..7fe55aa7261 --- /dev/null +++ b/odoo/data/upgrade/10_0_4/ir.filters.csv @@ -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 diff --git a/odoo/local-src/specific_crm/__manifest__.py b/odoo/local-src/specific_crm/__manifest__.py index 017c55cfc06..514c7b9bfe3 100644 --- a/odoo/local-src/specific_crm/__manifest__.py +++ b/odoo/local-src/specific_crm/__manifest__.py @@ -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, } diff --git a/odoo/local-src/specific_crm/models/__init__.py b/odoo/local-src/specific_crm/models/__init__.py index 26157d65394..514bcf16491 100644 --- a/odoo/local-src/specific_crm/models/__init__.py +++ b/odoo/local-src/specific_crm/models/__init__.py @@ -7,3 +7,4 @@ from . import crm_lead from . import survey from . import crm_team +from . import project_task \ No newline at end of file diff --git a/odoo/local-src/specific_crm/models/crm_lead.py b/odoo/local-src/specific_crm/models/crm_lead.py index 7cab3309a17..51f34ba3146 100644 --- a/odoo/local-src/specific_crm/models/crm_lead.py +++ b/odoo/local-src/specific_crm/models/crm_lead.py @@ -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): @@ -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}) diff --git a/odoo/local-src/specific_crm/models/project_task.py b/odoo/local-src/specific_crm/models/project_task.py new file mode 100644 index 00000000000..05bbd38ca25 --- /dev/null +++ b/odoo/local-src/specific_crm/models/project_task.py @@ -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') diff --git a/odoo/local-src/specific_crm/views/project_task.xml b/odoo/local-src/specific_crm/views/project_task.xml new file mode 100644 index 00000000000..64c4fd5c746 --- /dev/null +++ b/odoo/local-src/specific_crm/views/project_task.xml @@ -0,0 +1,21 @@ + + + + + project.task.form lead + project.task + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/odoo/local-src/specific_sale/__manifest__.py b/odoo/local-src/specific_sale/__manifest__.py index 5578414bd52..eb713cbfb07 100644 --- a/odoo/local-src/specific_sale/__manifest__.py +++ b/odoo/local-src/specific_sale/__manifest__.py @@ -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", diff --git a/odoo/local-src/specific_sale/models/sale_order.py b/odoo/local-src/specific_sale/models/sale_order.py index f63ec99d7e1..e39b1c44752 100644 --- a/odoo/local-src/specific_sale/models/sale_order.py +++ b/odoo/local-src/specific_sale/models/sale_order.py @@ -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 diff --git a/odoo/migration.yml b/odoo/migration.yml index 9fcd3599e90..d0c1daacd90 100644 --- a/odoo/migration.yml +++ b/odoo/migration.yml @@ -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 @@ -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 @@ -81,3 +83,4 @@ migration: - l10n_us - l10n_de_skr03 - website_sale + - website_sale_options diff --git a/odoo/songs/install/roctool_vars.py b/odoo/songs/install/roctool_vars.py index b32d9216d46..9678bb03947 100644 --- a/odoo/songs/install/roctool_vars.py +++ b/odoo/songs/install/roctool_vars.py @@ -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 = [ diff --git a/odoo/songs/install/sale.py b/odoo/songs/install/sale.py index 71ab7d49bd7..88a01d88eca 100644 --- a/odoo/songs/install/sale.py +++ b/odoo/songs/install/sale.py @@ -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) diff --git a/odoo/songs/upgrade/10_0_4/__init__.py b/odoo/songs/upgrade/10_0_4/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/odoo/songs/upgrade/10_0_4/crm.py b/odoo/songs/upgrade/10_0_4/crm.py new file mode 100644 index 00000000000..865a529f01a --- /dev/null +++ b/odoo/songs/upgrade/10_0_4/crm.py @@ -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) diff --git a/odoo/songs/upgrade/__init__.py b/odoo/songs/upgrade/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/odoo/src b/odoo/src index d11f10f2da6..a206ad71bb7 160000 --- a/odoo/src +++ b/odoo/src @@ -1 +1 @@ -Subproject commit d11f10f2da6c7c261a43b3206936dbab6bb3116c +Subproject commit a206ad71bb7ff3456d0e6df7b5224194e5741995