product_library adds some fields to product and some utilities addons from OCA
This commit is contained in:
parent
9145e0cabe
commit
6c8876b991
334 changed files with 92878 additions and 0 deletions
2
mass_editing/models/__init__.py
Normal file
2
mass_editing/models/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
from . import mass_editing
|
||||
from . import mass_editing_line
|
45
mass_editing/models/ir_model_fields.py
Normal file
45
mass_editing/models/ir_model_fields.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# This module uses OpenERP, Open Source Management Solution Framework.
|
||||
# Copyright (C):
|
||||
# 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
|
||||
|
||||
class IrModelFields(orm.Model):
|
||||
_inherit = 'ir.model.fields'
|
||||
|
||||
def search(
|
||||
self, cr, uid, args, offset=0, limit=0, order=None, context=None,
|
||||
count=False):
|
||||
model_domain = []
|
||||
for domain in args:
|
||||
if (len(domain) > 2 and
|
||||
domain[0] == 'model_id' and
|
||||
isinstance(domain[2], basestring)):
|
||||
model_domain += [
|
||||
('model_id', 'in', map(int, domain[2][1:-1].split(',')))
|
||||
]
|
||||
else:
|
||||
model_domain.append(domain)
|
||||
return super(IrModelFields, self).search(
|
||||
cr, uid, model_domain, offset=offset, limit=limit, order=order,
|
||||
context=context, count=count
|
||||
)
|
25
mass_editing/models/mass_editing.py
Normal file
25
mass_editing/models/mass_editing.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class MassEditing(models.Model):
|
||||
_name = "mass.editing"
|
||||
_inherit = "mass.operation.mixin"
|
||||
_description = "Mass Editing"
|
||||
|
||||
_wizard_model_name = "mass.editing.wizard"
|
||||
|
||||
line_ids = fields.One2many(
|
||||
comodel_name="mass.editing.line", inverse_name="mass_editing_id"
|
||||
)
|
||||
apply_domain_in_lines = fields.Boolean(
|
||||
string="Apply domain in lines",
|
||||
compute="_compute_apply_domain_in_lines"
|
||||
)
|
||||
|
||||
@api.depends("line_ids")
|
||||
def _compute_apply_domain_in_lines(self):
|
||||
for record in self:
|
||||
record.apply_domain_in_lines = any(record.line_ids.mapped("apply_domain"))
|
52
mass_editing/models/mass_editing_line.py
Normal file
52
mass_editing/models/mass_editing_line.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class MassEditingLine(models.Model):
|
||||
_name = "mass.editing.line"
|
||||
_order = "sequence,field_id"
|
||||
_description = "Mass Editing Line"
|
||||
|
||||
sequence = fields.Integer()
|
||||
|
||||
mass_editing_id = fields.Many2one(comodel_name="mass.editing")
|
||||
|
||||
model_id = fields.Many2one(
|
||||
comodel_name="ir.model", related="mass_editing_id.model_id"
|
||||
)
|
||||
|
||||
field_id = fields.Many2one(
|
||||
comodel_name="ir.model.fields",
|
||||
string="Field",
|
||||
domain="["
|
||||
"('name', '!=', '__last_update'),"
|
||||
"('ttype', 'not in', ['reference', 'function']),"
|
||||
"('model_id', '=', model_id)"
|
||||
"]",
|
||||
)
|
||||
|
||||
widget_option = fields.Char(
|
||||
string="Widget Option",
|
||||
store=True,
|
||||
readonly=False,
|
||||
help="Add widget text that will be used"
|
||||
" to display the field in the wizard. Example :\n"
|
||||
"'many2many_tags', 'selection'"
|
||||
)
|
||||
|
||||
apply_domain = fields.Boolean(
|
||||
default=False,
|
||||
string="Apply domain",
|
||||
help="Apply default domain related to field"
|
||||
)
|
||||
|
||||
@api.onchange("field_id")
|
||||
def _onchange_field_id(self):
|
||||
if self.field_id and self.field_id.ttype == "many2many":
|
||||
self.widget_option = "many2many_tags"
|
||||
elif self.field_id and self.field_id.ttype == "Binary":
|
||||
if "image" in self.field_id.name or "logo" in self.field_id.name:
|
||||
self.widget_option = "image"
|
138
mass_editing/models/mass_object.py
Normal file
138
mass_editing/models/mass_object.py
Normal file
|
@ -0,0 +1,138 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# This module uses OpenERP, Open Source Management Solution Framework.
|
||||
# Copyright (C):
|
||||
# 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class MassObject(orm.Model):
|
||||
_name = "mass.object"
|
||||
|
||||
_columns = {
|
||||
'name': fields.char("Name", size=64, required=True, select=1),
|
||||
'model_id': fields.many2one(
|
||||
'ir.model', 'Model', required=True, select=1),
|
||||
'field_ids': fields.many2many(
|
||||
'ir.model.fields', 'mass_field_rel', 'mass_id', 'field_id',
|
||||
'Fields'),
|
||||
'ref_ir_act_window': fields.many2one(
|
||||
'ir.actions.act_window', 'Sidebar Action', readonly=True,
|
||||
help="Sidebar action to make this template available on records \
|
||||
of the related document model"),
|
||||
'ref_ir_value': fields.many2one(
|
||||
'ir.values', 'Sidebar Button', readonly=True,
|
||||
help="Sidebar button to open the sidebar action"),
|
||||
'model_ids': fields.many2many('ir.model', string='Model List')
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
('name_uniq', 'unique (name)', _('Name must be unique!')),
|
||||
]
|
||||
|
||||
def onchange_model_id(self, cr, uid, ids, model_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not model_id:
|
||||
return {'value': {'model_ids': [(6, 0, [])]}}
|
||||
model_ids = [model_id]
|
||||
model_obj = self.pool['ir.model']
|
||||
active_model_obj = self.pool.get(model_obj.browse(
|
||||
cr, uid, model_id).model)
|
||||
if active_model_obj._inherits:
|
||||
for key, val in active_model_obj._inherits.items():
|
||||
found_model_ids = model_obj.search(
|
||||
cr, uid, [('model', '=', key)], context=context)
|
||||
model_ids += found_model_ids
|
||||
return {'value': {'model_ids': [(6, 0, model_ids)]}}
|
||||
|
||||
def create_action(self, cr, uid, ids, context=None):
|
||||
vals = {}
|
||||
action_obj = self.pool['ir.actions.act_window']
|
||||
ir_values_obj = self.pool['ir.values']
|
||||
for data in self.browse(cr, uid, ids, context=context):
|
||||
src_obj = data.model_id.model
|
||||
button_name = _('Mass Editing (%s)') % data.name
|
||||
vals['ref_ir_act_window'] = action_obj.create(
|
||||
cr, SUPERUSER_ID,
|
||||
{
|
||||
'name': button_name,
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'mass.editing.wizard',
|
||||
'src_model': src_obj,
|
||||
'view_type': 'form',
|
||||
'context': "{'mass_editing_object' : %d}" % (data.id),
|
||||
'view_mode': 'form,tree',
|
||||
'target': 'new',
|
||||
'auto_refresh': 1,
|
||||
},
|
||||
context)
|
||||
vals['ref_ir_value'] = ir_values_obj.create(
|
||||
cr, SUPERUSER_ID,
|
||||
{
|
||||
'name': button_name,
|
||||
'model': src_obj,
|
||||
'key2': 'client_action_multi',
|
||||
'value': (
|
||||
"ir.actions.act_window," +
|
||||
str(vals['ref_ir_act_window'])),
|
||||
'object': True,
|
||||
},
|
||||
context)
|
||||
self.write(
|
||||
cr, uid, ids,
|
||||
{
|
||||
'ref_ir_act_window': vals.get('ref_ir_act_window', False),
|
||||
'ref_ir_value': vals.get('ref_ir_value', False),
|
||||
},
|
||||
context)
|
||||
return True
|
||||
|
||||
def unlink_action(self, cr, uid, ids, context=None):
|
||||
for template in self.browse(cr, uid, ids, context=context):
|
||||
try:
|
||||
if template.ref_ir_act_window:
|
||||
act_window_obj = self.pool['ir.actions.act_window']
|
||||
act_window_obj.unlink(
|
||||
cr, SUPERUSER_ID, [template.ref_ir_act_window.id],
|
||||
context=context)
|
||||
if template.ref_ir_value:
|
||||
ir_values_obj = self.pool['ir.values']
|
||||
ir_values_obj.unlink(
|
||||
cr, SUPERUSER_ID, template.ref_ir_value.id,
|
||||
context=context)
|
||||
except:
|
||||
raise orm.except_orm(
|
||||
_("Warning"),
|
||||
_("Deletion of the action record failed."))
|
||||
return True
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
self.unlink_action(cr, uid, ids, context=context)
|
||||
return super(MassObject, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
def copy(self, cr, uid, record_id, default=None, context=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
default.update({'name': '', 'field_ids': []})
|
||||
return super(MassObject, self).copy(
|
||||
cr, uid, record_id, default, context=context)
|
Loading…
Add table
Add a link
Reference in a new issue