-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OCA#456 from TDu/bssfw-40
BSSFW-40 Add serial_owner
- Loading branch information
Showing
10 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
{ | ||
"name": "sf_serial_owner", | ||
"description": "Keep track of serial number link to customer and reseller", | ||
"version": "10.0.1.0.0", | ||
"category": "", | ||
"website": "https://camptocamp.com", | ||
"author": "Camptocamp", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"product", | ||
"stock", | ||
"sf_rma", | ||
"sf_partner_entity_type", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/serial_owner.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import serial_owner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
from odoo import api, fields, models, _ | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class SerialOwner(models.Model): | ||
_name = 'serial.owner' | ||
_inherit = 'mail.thread' | ||
|
||
_description = 'Serial number onwership' | ||
|
||
serial_number_id = fields.Many2one( | ||
comodel_name='stock.production.lot', | ||
string='Serial Number', | ||
required=True, | ||
) | ||
product_id = fields.Many2one( | ||
related='serial_number_id.product_id', | ||
string='Product', | ||
) | ||
product_name = fields.Char( | ||
related='serial_number_id.product_id.name', | ||
string='Product', | ||
readonly=True, | ||
) | ||
reseller_id = fields.Many2one( | ||
comodel_name='res.partner', | ||
string='Reseller', | ||
domain=lambda self: self._get_reseller_domain(), | ||
track_visibility='onchange', | ||
) | ||
customer_id = fields.Many2one( | ||
comodel_name='res.partner', | ||
string='Customer', | ||
domain=[('customer', '=', True)], | ||
track_visibility='onchange', | ||
) | ||
shipped_to_reseller_on = fields.Date( | ||
string='Shipped on', | ||
track_visibility='onchange', | ||
) | ||
registred_by_customer_on = fields.Date( | ||
string='Registred on', | ||
track_visibility='onchange', | ||
) | ||
|
||
@api.multi | ||
def _get_reseller_domain(self): | ||
entity = self.env.ref( | ||
'sf_partner_entity_type.entity_dealer', | ||
raise_if_not_found=False | ||
) | ||
if not entity: | ||
raise UserError( | ||
_("Entity type \"Dealer\" was removed. Please update" | ||
" sf_partner_enityt_type module to restore it.")) | ||
return [('entity_type_id', '=', entity.id), | ||
('customer', '=', 'True')] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_serial_owner_reader,serial.owner reader,model_serial_owner,sf_rma.group_rma_reader,1,0,0,0 | ||
access_serial_owner_user,serial.owner user,model_serial_owner,sf_rma.group_rma_user,1,1,1,0 | ||
access_serial_owner_manager,serial.owner reader,model_serial_owner,sf_rma.group_rma_manager,1,1,1,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="view_serial_owner_form" model="ir.ui.view"> | ||
<field name="name">serial.owner.form</field> | ||
<field name="model">serial.owner</field> | ||
<field name="arch" type="xml"> | ||
<form string="Serial Owner"> | ||
<header> | ||
</header> | ||
<sheet> | ||
<div class="oe_title"> | ||
<label for="serial_number_id" class="oe_edit_only"/> | ||
<h1><field name="serial_number_id"/></h1> | ||
</div> | ||
<group name="main"> | ||
<group name="product_info"> | ||
<field name="product_name"/> | ||
</group> | ||
<group></group> | ||
<group name="customer_info"> | ||
<field name="customer_id"/> | ||
<field name="registred_by_customer_on"/> | ||
</group> | ||
<group name="reseller_info"> | ||
<field name="reseller_id"/> | ||
<field name="shipped_to_reseller_on"/> | ||
</group> | ||
</group> | ||
</sheet> | ||
<div class="oe_chatter"> | ||
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/> | ||
<field name="message_ids" widget="mail_thread"/> | ||
</div> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="view_serial_owner_tree" model="ir.ui.view"> | ||
<field name="name">serial.owner.tree</field> | ||
<field name="model">serial.owner</field> | ||
<field name="arch" type="xml"> | ||
<tree string="Serial Owner"> | ||
<field name="customer_id"/> | ||
<field name="serial_number_id"/> | ||
<field name="product_id"/> | ||
<field name="reseller_id"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="view_serialowner_filter" model="ir.ui.view"> | ||
<field name="name">serial.owner.filter</field> | ||
<field name="model">serial.owner</field> | ||
<field name="arch" type="xml"> | ||
<search string="Search serial owner"> | ||
<field name="serial_number_id" string="Serial number"/> | ||
<field name="product_name" string="Product name"/> | ||
<field name="reseller_id"/> | ||
<field name="customer_id"/> | ||
<group expand="0" string="Group By"> | ||
<filter string="Reseller" domain="[]" context="{'group_by':'reseller_id'}"/> | ||
<filter string="Customer" domain="[]" context="{'group_by':'customer_id'}"/> | ||
<filter string="Product" domain="[]" context="{'group_by':'product_id'}"/> | ||
</group> | ||
</search> | ||
|
||
</field> | ||
</record> | ||
|
||
<record id="action_serial_owner" model="ir.actions.act_window"> | ||
<field name="name">Serial Owner</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">serial.owner</field> | ||
<field name="view_type">form</field> | ||
<field name="view_id" ref="view_serial_owner_tree"/> | ||
<field name="search_view_id" ref="view_serialowner_filter"/> | ||
</record> | ||
|
||
<menuitem action="action_serial_owner" | ||
id="menu_action_serial_owner" | ||
parent="stock.menu_stock_inventory_control" | ||
sequence="120"/> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- update xmlid for entity_type "Dealer" | ||
-- reuse old entity_type and point new xmlid to it | ||
UPDATE ir_model_data SET res_id = (SELECT res_id FROM ir_model_data WHERE module = '__setup__' AND name = 'res_partner_entity_dealer') WHERE module = 'sf_partner_entity_type' AND name = 'entity_dealer'; | ||
-- delete new entity not anymore related to an xmlid | ||
DELETE FROM res_partner_entity_type WHERE name = 'Dealer' AND id != (SELECT res_id FROM ir_model_data WHERE module = 'sf_partner_entity_type' AND name = 'entity_dealer'); |