Membuat Template Project Odoo12

Assalamu'alaikum warohmatullah,

Tidak sedikit perusahaan yang memiliki kerangka kerja yang baku saat mengerjakan sebuah project, maka kesempatan kali ini saya ingin berbagi pengalaman tentang bagaimana membuat template project di odoo 12.

berikut tahapan yang kita lakukan :

1. Seperti biasa, mari kita membuat modul bernama project_template (bebas)

2. Tambahkan depends 'project' pada field __manifest__.py

3. Buka file models/model.py  dan masukkan kode di bawah ini 

from odoo import models, fields, api

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

	project_management = fields.Boolean(string='Project Management')
	preparation = fields.Boolean(string='Preparation')
	mobilization = fields.Boolean(string='Mobilization')
	operation = fields.Boolean(string='Operation')
	demobilization = fields.Boolean(string='Demobilization')
	reporting = fields.Boolean(string='Reporting')
	others = fields.Boolean(string='Others')

class CreateProjectTemplate(models.Model):
	_inherit = 'project.project'

	@api.model
	def create(self, values):
		stages = []
		obj_task_type = self.env['project.task.type'].search(
			['|', '|','|','|','|','|',
			('project_management','=',True),
			('preparation','=',True),
			('mobilization','=',True),
			('operation','=',True),
			('demobilization','=',True),
			('reporting','=',True),
			('others','=',True),
			])

		for x in obj_task_type:
			stages.append(x.id)

		values['type_ids'] = [(6,0,stages)]
		return super(CreateProjectTemplate, self).create(values)

4. setelah itu mari kita buat template tipe project dengan membuat file data/stage_templates.xml dan masukkan kode berikut ini :

<odoo>
	<data>
	<!-- Record Templates Project Stage -->
    <record id="stage_project_management" model="project.task.type">
      <field name="sequence">1</field>
      <field name="name">Project Management</field>
      <field name="project_management" eval="    </record>

    <record id="stage_preparation" model="project.task.type">
      <field name="sequence">2</field>
      <field name="name">Preparation</field>
      <field name="preparation" eval="True"/>    </record>

    <record id="stage_mobilization" model="project.task.type">
      <field name="sequence">3</field>
      <field name="name">Mobilization</field>
      <field name="mobilization" eval="True"/>
    </record> <record id="stage_operation" model="project.task.type"> <field name="sequence">4</field> <field name="name">Operation</field> <field name="operation" eval="True"/> </record> <record id="stage_demobilization" model="project.task.type"> <field name="sequence">5</field> <field name="name">Demobilization</field> <field name="demobilization" eval="True"/> </record> <record id="stage_reporting" model="project.task.type"> <field name="sequence">6</field> <field name="name">Reporting</field> <field name="reporting" eval="True"/> </record> <record id="stage_others" model="project.task.type"> <field name="sequence">7</field> <field name="name">Others</field> <field name="others" eval="True"/> </record> </data> </odoo>

Jika semua tahapan sudah selesai, mari kita install dan mencoba modulnya. 

Sekian artikel dari saya, kurang-lebihnya saya mohon maaf.

Wassalamu'alaikum warohmatullah wabarokatuh




Membuat payment method baru untuk point of sale odoo 8