openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #05138
[Merge] lp:~akretion-team/project-service/project-service-base-sale-project into lp:project-service
Sébastien BEAU - http://www.akretion.com has proposed merging lp:~akretion-team/project-service/project-service-base-sale-project into lp:project-service.
Requested reviews:
Project Core Editors (project-core-editors)
For more details, see:
https://code.launchpad.net/~akretion-team/project-service/project-service-base-sale-project/+merge/211960
Hi,
We are cleanning and improving our OpenERP, so we plan to contribute everything here !
Let's start with some basic module
Here it's just a base module in order to link correctly a project and a sale order and also to create a project from a sale order.
No big thing, it's an base module that can be usefull in many case
Thanks for your review
--
https://code.launchpad.net/~akretion-team/project-service/project-service-base-sale-project/+merge/211960
Your team Project Core Editors is requested to review the proposed merge of lp:~akretion-team/project-service/project-service-base-sale-project into lp:project-service.
=== added directory 'base_sale_project'
=== added file 'base_sale_project/__init__.py'
--- base_sale_project/__init__.py 1970-01-01 00:00:00 +0000
+++ base_sale_project/__init__.py 2014-03-20 14:52:43 +0000
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+# Module for OpenERP
+# Copyright (C) 2014 Akretion (http://www.akretion.com).
+# Copyright (C) 2010-2013 Akretion LDTA (<http://www.akretion.com>)
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+from . import sale
+from . import project
=== added file 'base_sale_project/__openerp__.py'
--- base_sale_project/__openerp__.py 1970-01-01 00:00:00 +0000
+++ base_sale_project/__openerp__.py 2014-03-20 14:52:43 +0000
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+# Module for OpenERP
+# Copyright (C) 2010-2013 Akretion LDTA (<http://www.akretion.com>).
+# Copyright (C) 2013 Akretion (http://www.akretion.com).
+# @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+
+{
+ 'name': 'base_sale_project',
+ 'version': '7.0',
+ 'category': 'Generic Modules/Others',
+ 'license': 'AGPL-3',
+ 'description': """This module is a base module that give the posibility to
+ create a project from a quotation""",
+ 'author': 'Akretion',
+ 'website': 'http://www.akretion.com/',
+ 'depends': [
+ 'project',
+ 'sale',
+ ],
+ 'demo': [],
+ 'data': [
+ 'sale_view.xml',
+ ],
+ 'installable': True,
+}
=== added file 'base_sale_project/project.py'
--- base_sale_project/project.py 1970-01-01 00:00:00 +0000
+++ base_sale_project/project.py 2014-03-20 14:52:43 +0000
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+# Module for OpenERP
+# Copyright (C) 2014 Akretion (http://www.akretion.com).
+# Copyright (C) 2010-2013 Akretion LDTA (<http://www.akretion.com>)
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+
+from openerp.osv import fields, orm
+
+
+class project_project(orm.Model):
+ _inherit = "project.project"
+
+ _columns = {
+ 'order_ids': fields.one2many('sale.order', 'true_project_id', 'Orders'),
+ }
=== added file 'base_sale_project/sale.py'
--- base_sale_project/sale.py 1970-01-01 00:00:00 +0000
+++ base_sale_project/sale.py 2014-03-20 14:52:43 +0000
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+# Module for OpenERP
+# Copyright (C) 2014 Akretion (http://www.akretion.com).
+# Copyright (C) 2010-2013 Akretion LDTA (<http://www.akretion.com>)
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+from openerp.osv import fields, orm
+from datetime import date
+
+
+class sale_order(orm.Model):
+ _inherit = "sale.order"
+
+ _columns = {
+ 'true_project_id': fields.many2one(
+ 'project.project',
+ 'Project',
+ readonly=True,
+ states={'draft': [('readonly', False)]}
+ ),
+ }
+
+ def true_project_id_change(self, cr, uid, ids, true_project_id):
+ project_obj = self.pool['project.project']
+ if true_project_id:
+ project = project_obj.browse(cr, uid, true_project_id)
+ return {'value': {'project_id': project.analytic_account_id.id}}
+ return {}
+
+ def _prepare_project_vals(self, cr, uid, order, context=None):
+ name = u" %s - %s - %s" % (
+ order.partner_id.name,
+ date.today().year,
+ order.name)
+ return {
+ 'user_id': order.user_id.id,
+ 'name': name,
+ 'partner_id': order.partner_id.id,
+ }
+
+ def create_project(self, cr, uid, ids, context=None):
+ project_obj = self.pool['project.project']
+ if context is None:
+ context = {}
+ for order in self.browse(cr, uid, ids, context=context):
+ vals = self._prepare_project_vals(cr, uid, order, context)
+ project_id = project_obj.create(cr, uid, vals, context=context)
+ project = project_obj.browse(cr, uid, project_id, context=context)
+ order.write({
+ 'true_project_id': project_id,
+ 'project_id': project.analytic_account_id.id
+ })
+ return True
=== added file 'base_sale_project/sale_view.xml'
--- base_sale_project/sale_view.xml 1970-01-01 00:00:00 +0000
+++ base_sale_project/sale_view.xml 2014-03-20 14:52:43 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="view_order_form" model="ir.ui.view">
+ <field name="name">view_project_quotation_order_form</field>
+ <field name="model">sale.order</field>
+ <field name="inherit_id" ref="sale.view_order_form" />
+ <field name="arch" type="xml">
+ <field name="project_id" position="replace">
+ <field name="project_id" invisible="1" />
+ <group col="4" colspan="2">
+ <field name="true_project_id"
+ on_change="true_project_id_change(true_project_id)"
+ domain="[('partner_id','=',partner_id)]"
+ attrs="{'readonly':[('partner_id','=', False)]}"/>
+ <group attrs="{'invisible':[('true_project_id', '!=', False)]}">
+ <button name="create_project" states="draft"
+ string="Create Project"
+ type="object" icon="gtk-execute" />
+ </group>
+ </group>
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>