mirror of
https://gitlab.com/sonalarora/tra_backend.git
synced 2025-12-18 02:39:10 +02:00
work on mks
This commit is contained in:
10
mks_delivery/__init__.py
Normal file
10
mks_delivery/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import models
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
44
mks_delivery/__manifest__.py
Normal file
44
mks_delivery/__manifest__.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'MKS Delivery',
|
||||
'version': '13.0.1.0',
|
||||
'sequence': 1,
|
||||
'category': 'Generic Modules/Sales Management',
|
||||
'description':
|
||||
"""
|
||||
This Module add below functionality into odoo
|
||||
|
||||
1.Sale Field Service Task\n
|
||||
|
||||
""",
|
||||
'summary': 'MKS Delivery',
|
||||
'author': 'Masterkey',
|
||||
'website': 'irfan@masterkeyglobal.com',
|
||||
'depends': ['sale_management','industry_fsm','project','contacts'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/res_config_views.xml',
|
||||
'views/sale_view.xml',
|
||||
'views/zone_form_view.xml',
|
||||
'views/city_form_view.xml',
|
||||
'views/res_partner_view.xml',
|
||||
'views/project_task_view.xml',
|
||||
],
|
||||
'demo': [],
|
||||
'test': [],
|
||||
'css': [],
|
||||
'qweb': [],
|
||||
'js': [],
|
||||
'images': [],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'auto_install': False,
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
17
mks_delivery/models/__init__.py
Normal file
17
mks_delivery/models/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import res_config
|
||||
from . import sale
|
||||
from . import zone_zone
|
||||
from . import res_partner
|
||||
from . import city_city
|
||||
from . import project_task
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
25
mks_delivery/models/city_city.py
Normal file
25
mks_delivery/models/city_city.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class city_city(models.Model):
|
||||
_name = 'city.city'
|
||||
|
||||
name = fields.Char(string="Name")
|
||||
code = fields.Char(string="Code")
|
||||
zone_id = fields.Many2one('zone.zone',string="Zone")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
66
mks_delivery/models/project_task.py
Normal file
66
mks_delivery/models/project_task.py
Normal file
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from odoo import models, fields, api,_
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class project_task(models.Model):
|
||||
_inherit='project.task'
|
||||
|
||||
|
||||
state = fields.Selection([
|
||||
('unassigned', 'Unassigned'),
|
||||
('assigned','Assigned'),('accepted','Accepted'),
|
||||
('started','Started'),('delivered','Delivered'),
|
||||
('cancel','Cancel'),('issue','Issue'),
|
||||
('paid','Paid'),('non_paid','Non Paid'),
|
||||
], string='Status', readonly=True, copy=False, default='unassigned')
|
||||
|
||||
zone_id = fields.Many2one('zone.zone',string="Zone")
|
||||
|
||||
def action_assign(self):
|
||||
self.state = 'assigned'
|
||||
return True
|
||||
|
||||
def action_accept(self):
|
||||
self.state = 'accepted'
|
||||
return True
|
||||
|
||||
def action_start(self):
|
||||
self.state = 'started'
|
||||
return True
|
||||
|
||||
def action_delivery(self):
|
||||
self.state = 'delivered'
|
||||
return True
|
||||
|
||||
def action_cancel(self):
|
||||
self.state = 'cancel'
|
||||
return True
|
||||
|
||||
def action_issue(self):
|
||||
self.state = 'issue'
|
||||
return True
|
||||
|
||||
def action_paid(self):
|
||||
self.state = 'paid'
|
||||
return True
|
||||
|
||||
def action_non_paid(self):
|
||||
self.state = 'non_paid'
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
24
mks_delivery/models/res_config.py
Normal file
24
mks_delivery/models/res_config.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
project_id = fields.Many2one('project.project',string='Project' ,readonly=False)
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
project_id = fields.Many2one(related='company_id.project_id',readonly=False, string='Project')
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
22
mks_delivery/models/res_partner.py
Normal file
22
mks_delivery/models/res_partner.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from odoo import models, fields, api,_
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class res_partner(models.Model):
|
||||
_inherit='res.partner'
|
||||
|
||||
city_id = fields.Many2one('city.city',string="City")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
63
mks_delivery/models/sale.py
Normal file
63
mks_delivery/models/sale.py
Normal file
@@ -0,0 +1,63 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from odoo import models, fields, api,_
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class sale_order(models.Model):
|
||||
_inherit='sale.order'
|
||||
|
||||
task_id = fields.Many2one('project.task',string='Field Services Task', \
|
||||
copy=False)
|
||||
|
||||
def services_task_values(self):
|
||||
if not self.company_id.project_id:
|
||||
raise ValidationError(_('Project - Field Service Task not configured properly !'))
|
||||
|
||||
project_id = self.company_id.project_id and self.company_id.project_id.id \
|
||||
or False
|
||||
notes = "Notes:" + '<br/>'+"-----------------------"+'<br/>'+"Product: "\
|
||||
+'<br/><br/>'
|
||||
for line in self.order_line:
|
||||
notes += str(line.product_id.name )+" : "+ str(line.product_uom_qty)\
|
||||
+" qty" +'<br/>'
|
||||
vals = {'name':self.name,
|
||||
'partner_id': self.partner_id and self.partner_id.id or False,
|
||||
'planned_date_begin': self.date_order,
|
||||
'planned_date_end': self.date_order,
|
||||
'project_id':project_id,
|
||||
'description':notes,
|
||||
'user_id':False,
|
||||
'zone_id':self.partner_id.city_id and self.partner_id.city_id.zone_id and \
|
||||
self.partner_id.city_id.zone_id.id or False,
|
||||
|
||||
}
|
||||
return vals
|
||||
|
||||
def _prepare_project_task(self,task_values):
|
||||
project_task_ids = self.env['project.task'].create(task_values)
|
||||
self.task_id = project_task_ids.id
|
||||
return True
|
||||
|
||||
def action_confirm(self):
|
||||
res =super(sale_order,self).action_confirm()
|
||||
task_values = self.services_task_values()
|
||||
self._prepare_project_task(task_values)
|
||||
return res
|
||||
|
||||
def action_view_task(self):
|
||||
action = self.env.ref('industry_fsm.project_task_action_fsm').read()[0]
|
||||
task_id = self.mapped('task_id')
|
||||
if task_id:
|
||||
action['views'] = [
|
||||
(self.env.ref('industry_fsm.project_task_view_form').id, 'form')]
|
||||
action['res_id'] = task_id.id
|
||||
return action
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
26
mks_delivery/models/zone_zone.py
Normal file
26
mks_delivery/models/zone_zone.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class zone_zone(models.Model):
|
||||
_name = 'zone.zone'
|
||||
|
||||
name = fields.Char(string="Name",required=True)
|
||||
code = fields.Char(string="Code")
|
||||
zone_ids = fields.One2many('city.city','zone_id',string='Zone', \
|
||||
copy=False)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
3
mks_delivery/security/ir.model.access.csv
Normal file
3
mks_delivery/security/ir.model.access.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_zone_zone","zone_zon","model_zone_zone",,1,1,1,1
|
||||
"access_city_city","city_city","model_city_city",,1,1,1,1
|
||||
|
42
mks_delivery/views/city_form_view.xml
Normal file
42
mks_delivery/views/city_form_view.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="city_form_view" model="ir.ui.view">
|
||||
<field name="name">city.form.view</field>
|
||||
<field name="model">city.city</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="City">
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="code"/>
|
||||
<field name="zone_id"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="city_tree_View" model="ir.ui.view">
|
||||
<field name="name">city.tree.view</field>
|
||||
<field name="model">city.city</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="City">
|
||||
<field name='name'/>
|
||||
<field name='code'/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_city_view" model="ir.actions.act_window">
|
||||
<field name="name">City</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">city.city</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem name= "City" id='menu_city_id' parent="contacts.res_partner_menu_config" action="action_city_view" sequence="21"/>
|
||||
</odoo>
|
||||
|
||||
100
mks_delivery/views/project_task_view.xml
Normal file
100
mks_delivery/views/project_task_view.xml
Normal file
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="project_task_view_zone" model="ir.ui.view">
|
||||
<field name="name">project.task.view.zone</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="inherit_id" ref="industry_fsm.project_task_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//sheet" position='before'>
|
||||
<header>
|
||||
<button name="action_assign" type="object" string="Assigned" states="unassigned" class="oe_highlight" />
|
||||
<button name="action_accept" type="object" string="Accept" states="assigned" class="oe_highlight" />
|
||||
<button name="action_start" type="object" string="Start" states="accepted,issue" class="oe_highlight" />
|
||||
<button name="action_delivery" type="object" string="Delivered" states="started" class="oe_highlight" />
|
||||
<button name="action_cancel" type="object" string="Cancel" states="started,issue" class="oe_highlight" />
|
||||
<button name="action_issue" type="object" string="Issue" states="started" class="oe_highlight" />
|
||||
|
||||
<button name="action_paid" type="object" string="Paid" states="delivered" class="oe_highlight" />
|
||||
<button name="action_non_paid" type="object" string="Non Paid" states="delivered" class="oe_highlight" />
|
||||
|
||||
|
||||
|
||||
<field name="state" widget="statusbar" statusbar_visible="unassigned,assigned,accepted,started,delivered"/>
|
||||
</header>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='project_id']" position="after">
|
||||
<field name="zone_id" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='name']" position="replace">
|
||||
<field name="name" string="Sale Order Number" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='project_id']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- search view-->
|
||||
<record id="project_task_Service_search" model="ir.ui.view">
|
||||
<field name="name">project.task.Service.search</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="inherit_id" ref="industry_fsm.project_task_view_search_fsm"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="zone_id" />
|
||||
<field name="state" />
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='groupby_stage']" position="replace"/>
|
||||
<xpath expr="//filter[@name='groupby_project']" position="replace"/>
|
||||
|
||||
<xpath expr="//filter[@name='groupby_company']" position="after">
|
||||
<filter string="Zone" name="zone_id" context="{'group_by':'zone_id'}" />
|
||||
<filter string="Status" name="state" context="{'group_by':'state'}"/>
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='planned_future']" position="after">
|
||||
<separator/>
|
||||
<filter string="Unassigned" name="unassigned" domain="[('state','=','unassigned')]"/>
|
||||
<filter string="Assigned" name="assigned" domain="[('state','=','assigned')]"/>
|
||||
<filter string="Accepted" name="accepted" domain="[('state','=','accepted')]"/>
|
||||
<filter string="Started" name="started" domain="[('state','=','started')]"/>
|
||||
<filter string="Delivered" name="delivered" domain="[('state','=','delivered')]"/>
|
||||
<filter string="Cancel" name="cancel" domain="[('state','=','cancel')]"/>
|
||||
<filter string="Issue" name="cancel" domain="[('state','=','issue')]"/>
|
||||
<filter string="Paid" name="paid" domain="[('state','=','paid')]"/>
|
||||
<filter string="Non Paid" name="non_paid" domain="[('state','=','non_paid')]"/>
|
||||
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<!-- tree vies-->
|
||||
<record id="project_task_list_view" model="ir.ui.view">
|
||||
<field name="name">project.task.list.view</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="inherit_id" ref="industry_fsm.project_task_view_list_fsm"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<xpath expr="//tree" position="replace">
|
||||
<tree string="Tasks" decoration-danger="state=='cancel'" decoration-info="state=='assigned'"
|
||||
decoration-success="state=='delivered'"
|
||||
decoration-warning="state=='issue'"
|
||||
decoration-primary="state=='started'" >
|
||||
|
||||
<field name="name" string="Sale Order Number"/>
|
||||
<field name="partner_id" />
|
||||
<field name="zone_id" />
|
||||
<field name="partner_phone" />
|
||||
<field name="partner_email" />
|
||||
<field name="user_id" invisible="context.get('user_invisible', False)"/>
|
||||
<field name="planned_date_begin"/>
|
||||
<field name="planned_date_end"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
24
mks_delivery/views/res_config_views.xml
Normal file
24
mks_delivery/views/res_config_views.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
<record id="res_config_sale_project" model="ir.ui.view">
|
||||
<field name="name">res.config.sale.project</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="priority" eval="50"/>
|
||||
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@data-key='sale_management']//h2" position="before">
|
||||
<h2>Project - Field Service Task</h2>
|
||||
<div class="row mt16 o_settings_container" id="product_deposit">
|
||||
<div class="col-xs-12 o_setting_box">
|
||||
<group>
|
||||
<field name="project_id" domain="[('is_fsm', '=', True)]" style="width:80%%"/>
|
||||
</group>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
|
||||
13
mks_delivery/views/res_partner_view.xml
Normal file
13
mks_delivery/views/res_partner_view.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="zone_res_partner_view_inherit" model="ir.ui.view">
|
||||
<field name="name">zone.res.partner.view.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='street2']" position="after" >
|
||||
<field name="city_id" placeholder="City" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
13
mks_delivery/views/sale_view.xml
Normal file
13
mks_delivery/views/sale_view.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="sale_task_view" model="ir.ui.view">
|
||||
<field name="name">sale.order.inherit</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='preview_sale_order']" position="before">
|
||||
<button type="object" name="action_view_task" attrs="{'invisible': [('state', 'not in',['sale','done'])]}" string='Field Services' class="oe_stat_button" icon="fa-align-justify" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
51
mks_delivery/views/zone_form_view.xml
Normal file
51
mks_delivery/views/zone_form_view.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="zone_form_view" model="ir.ui.view">
|
||||
<field name="name">zone.form.view</field>
|
||||
<field name="model">zone.zone</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Zone">
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="code"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Zone" >
|
||||
<field name='zone_ids'>
|
||||
<tree editable="bottom">
|
||||
<field name='name'/>
|
||||
<field name='code'/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="zone_zone_tree_View" model="ir.ui.view">
|
||||
<field name="name">zone.zone.tree.view</field>
|
||||
<field name="model">zone.zone</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Zone">
|
||||
<field name='name'/>
|
||||
<field name='code'/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_zone_view" model="ir.actions.act_window">
|
||||
<field name="name">Zone</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">zone.zone</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem name ="Zone" id='menu_zone_id' parent="contacts.res_partner_menu_config" action="action_zone_view" sequence="20"/>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user