Example #1
0
    def create(self, values):
        # Do not publish slide if user has not publisher rights
        channel = self.env['slide.channel'].browse(values['channel_id'])
        if not channel.can_publish:
            # 'website_published' is handled by mixin
            values['date_published'] = False

        if not values.get('index_content'):
            values['index_content'] = values.get('description')
        if values.get('slide_type') == 'infographic' and not values.get('image'):
            values['image'] = values['datas']
        if values.get('website_published') and not values.get('date_published'):
            values['date_published'] = datetime.datetime.now()
        if values.get('url') and not values.get('document_id'):
            doc_data = self._parse_document_url(values['url']).get('values', dict())
            for key, value in doc_data.items():
                values.setdefault(key, value)

        if 'image' in values:
            tools.image_resize_images(values, return_large=True)

        slide = super(Slide, self).create(values)

        if slide.website_published:
            slide._post_publication()
        return slide
 def create(self, values_list):
     for vals in values_list:
         tools.image_resize_images(vals)
     res = super(KarmaRank, self).create(values_list)
     users = self.env['res.users'].sudo().search([('karma', '>', 0)])
     users._recompute_rank()
     return res
Example #3
0
    def write(self, vals):
        # res.partner must only allow to set the company_id of a partner if it
        # is the same as the company of all users that inherit from this partner
        # (this is to allow the code from res_users to write to the partner!) or
        # if setting the company_id to False (this is compatible with any user
        # company)
        if vals.get('website'):
            vals['website'] = self._clean_website(vals['website'])
        if vals.get('parent_id'):
            vals['company_name'] = False
        if vals.get('company_id'):
            company = self.env['res.company'].browse(vals['company_id'])
            for partner in self:
                if partner.user_ids:
                    companies = set(user.company_id for user in partner.user_ids)
                    if len(companies) > 1 or company not in companies:
                        raise UserError(_("You can not change the company as the partner/user has multiple user linked with different companies."))
        tools.image_resize_images(vals)

        result = super(Partner, self).write(vals)
        for partner in self:
            if any(u.has_group('base.group_user') for u in partner.user_ids if u != self.env.user):
                self.env['res.users'].check_access_rights('write')
            partner._fields_sync(vals)
        return result
Example #4
0
    def write(self, vals):
        # res.partner must only allow to set the company_id of a partner if it
        # is the same as the company of all users that inherit from this partner
        # (this is to allow the code from res_users to write to the partner!) or
        # if setting the company_id to False (this is compatible with any user
        # company)
        if vals.get('website'):
            vals['website'] = self._clean_website(vals['website'])
        if vals.get('parent_id'):
            vals['company_name'] = False
        if vals.get('company_id'):
            company = self.env['res.company'].browse(vals['company_id'])
            for partner in self:
                if partner.user_ids:
                    companies = set(user.company_id for user in partner.user_ids)
                    if len(companies) > 1 or company not in companies:
                        raise UserError(_("You can not change the company as the partner/user has multiple user linked with different companies."))
        tools.image_resize_images(vals, sizes={'image': (1024, None)})

        result = True
        # To write in SUPERUSER on field is_company and avoid access rights problems.
        if 'is_company' in vals and self.user_has_groups('base.group_partner_manager') and not self.env.uid == SUPERUSER_ID:
            result = super(Partner, self.sudo()).write({'is_company': vals.get('is_company')})
            del vals['is_company']
        result = result and super(Partner, self).write(vals)
        for partner in self:
            if any(u.has_group('base.group_user') for u in partner.user_ids if u != self.env.user):
                self.env['res.users'].check_access_rights('write')
            partner._fields_sync(vals)
        return result
Example #5
0
    def create(self, vals_list):
        ''' Store the initial standard price in order to be able to retrieve the cost of a product template for a given date'''
        # TDE FIXME: context brol
        for vals in vals_list:
            tools.image_resize_images(vals)
        templates = super(ProductTemplate, self).create(vals_list)
        if "create_product_product" not in self._context:
            templates.with_context(create_from_tmpl=True).create_variant_ids()

        # This is needed to set given values to first variant after creation
        for template, vals in pycompat.izip(templates, vals_list):
            related_vals = {}
            if vals.get('barcode'):
                related_vals['barcode'] = vals['barcode']
            if vals.get('default_code'):
                related_vals['default_code'] = vals['default_code']
            if vals.get('standard_price'):
                related_vals['standard_price'] = vals['standard_price']
            if vals.get('volume'):
                related_vals['volume'] = vals['volume']
            if vals.get('weight'):
                related_vals['weight'] = vals['weight']
            if related_vals:
                template.write(related_vals)

        return templates
Example #6
0
File: hr.py Project: befks/odoo
 def write(self, vals):
     if 'address_home_id' in vals:
         account_id = vals.get('bank_account_id') or self.bank_account_id.id
         if account_id:
             self.env['res.partner.bank'].browse(account_id).partner_id = vals['address_home_id']
     tools.image_resize_images(vals)
     return super(Employee, self).write(vals)
Example #7
0
 def create(self, vals):
     ''' Store the initial standard price in order to be able to retrieve the cost of a product template for a given date'''
     # TDE FIXME: context brol
     tools.image_resize_images(vals)
     template = super(ProductTemplate, self).create(vals)
     if "create_product_product" not in self._context:
         template.create_variant_ids()
     return template
Example #8
0
 def write(self, vals):
     tools.image_resize_images(vals)
     res = super(ProductTemplate, self).write(vals)
     if 'attribute_line_ids' in vals or vals.get('active'):
         self.create_variant_ids()
     if 'active' in vals and not vals.get('active'):
         self.with_context(active_test=False).mapped('product_variant_ids').write({'active': vals.get('active')})
     return res
Example #9
0
 def write(self, vals):
     tools.image_resize_images(vals)
     res = super(ProductTemplate, self).write(vals)
     if "attribute_line_ids" in vals or vals.get("active"):
         self.create_variant_ids()
     if "active" in vals and not vals.get("active"):
         self.with_context(active_test=False).mapped("product_variant_ids").write({"active": vals.get("active")})
     return res
Example #10
0
 def create(self, vals):
     if vals.get('website'):
         vals['website'] = self._clean_website(vals['website'])
     if vals.get('parent_id'):
         vals['company_name'] = False
     tools.image_resize_images(vals)
     partner = super(Partner, self).create(vals)
     partner._fields_sync(vals)
     partner._handle_first_contact_creation()
     return partner
Example #11
0
 def create(self, vals):
     if vals.get('user_id'):
         vals.update(self._sync_user(self.env['res.users'].browse(vals['user_id'])))
     tools.image_resize_images(vals)
     employee = super(Employee, self).create(vals)
     if employee.department_id:
         self.env['mail.channel'].sudo().search([
             ('subscription_department_ids', 'in', employee.department_id.id)
         ])._subscribe_users()
     return employee
Example #12
0
 def create(self, vals):
     if vals.get('website'):
         vals['website'] = self._clean_website(vals['website'])
     # compute default image in create, because computing gravatar in the onchange
     # cannot be easily performed if default images are in the way
     if not vals.get('image'):
         vals['image'] = self._get_default_image(vals.get('type'), vals.get('is_company'), vals.get('parent_id'))
     partner = super(Partner, self).create(vals)
     partner._fields_sync(vals)
     partner._handle_first_contact_creation()
     tools.image_resize_images(vals)
     return partner
Example #13
0
 def create(self, vals):
     if vals.get('user_id'):
         vals.update(self._sync_user(self.env['res.users'].browse(vals['user_id'])))
     tools.image_resize_images(vals)
     employee = super(Employee, self).create(vals)
     url = '/web#%s' % url_encode({'action': 'hr.plan_wizard_action', 'active_id': employee.id, 'active_model': 'hr.employee'})
     employee._message_log(_('<b>Congratulations !</b> May I recommand you to setup an <a href="%s">onboarding plan ?</a>') % (url))
     if employee.department_id:
         self.env['mail.channel'].sudo().search([
             ('subscription_department_ids', 'in', employee.department_id.id)
         ])._subscribe_users()
     return employee
Example #14
0
    def write(self, values):
        if values.get('url') and values['url'] != self.url:
            doc_data = self._parse_document_url(values['url']).get('values', dict())
            for key, value in doc_data.items():
                values.setdefault(key, value)

        if 'image' in values:
            tools.image_resize_images(values, return_large=True)

        res = super(Slide, self).write(values)
        if values.get('website_published'):
            self.date_published = datetime.datetime.now()
            self._post_publication()
        return res
Example #15
0
 def create(self, vals_list):
     for vals in vals_list:
         if vals.get('website'):
             vals['website'] = self._clean_website(vals['website'])
         if vals.get('parent_id'):
             vals['company_name'] = False
         # compute default image in create, because computing gravatar in the onchange
         # cannot be easily performed if default images are in the way
         if not vals.get('image'):
             vals['image'] = self._get_default_image(vals.get('type'), vals.get('is_company'), vals.get('parent_id'))
         tools.image_resize_images(vals, sizes={'image': (1024, None)})
     partners = super(Partner, self).create(vals_list)
     for partner, vals in zip(partners, vals_list):
         partner._fields_sync(vals)
         partner._handle_first_contact_creation()
     return partners
Example #16
0
    def create(self, vals):
        tools.image_resize_images(vals)
        # Create channel and alias
        channel = super(Channel, self.with_context(
            alias_model_name=self._name, alias_parent_model_name=self._name, mail_create_nolog=True, mail_create_nosubscribe=True)
        ).create(vals)
        channel.alias_id.write({"alias_force_thread_id": channel.id, 'alias_parent_thread_id': channel.id})

        if vals.get('group_ids'):
            channel._subscribe_users()

        # make channel listen itself: posting on a channel notifies the channel
        if not self._context.get('mail_channel_noautofollow'):
            channel.message_subscribe(channel_ids=[channel.id])

        return channel
Example #17
0
 def write(self, vals):
     if 'address_home_id' in vals:
         account_id = vals.get('bank_account_id') or self.bank_account_id.id
         if account_id:
             self.env['res.partner.bank'].browse(account_id).partner_id = vals['address_home_id']
     if vals.get('user_id'):
         vals.update(self._sync_user(self.env['res.users'].browse(vals['user_id'])))
     tools.image_resize_images(vals)
     res = super(Employee, self).write(vals)
     if vals.get('department_id') or vals.get('user_id'):
         department_id = vals['department_id'] if vals.get('department_id') else self[:1].department_id.id
         # When added to a department or changing user, subscribe to the channels auto-subscribed by department
         self.env['mail.channel'].sudo().search([
             ('subscription_department_ids', 'in', department_id)
         ])._subscribe_users()
     return res
Example #18
0
 def create(self, vals_list):
     for vals in vals_list:
         if vals.get('website'):
             vals['website'] = self._clean_website(vals['website'])
         if vals.get('parent_id'):
             vals['company_name'] = False
         # compute default image in create, because computing gravatar in the onchange
         # cannot be easily performed if default images are in the way
         if not vals.get('image'):
             vals['image'] = self._get_default_image(vals.get('type'), vals.get('is_company'), vals.get('parent_id'))
         # no padding on the big image, because it's used as website logo
         tools.image_resize_images(vals, return_big=False)
         tools.image_resize_images(vals, return_medium=False, return_small=False, preserve_aspect_ratio=True)
     partners = super(Partner, self).create(vals_list)
     for partner, vals in zip(partners, vals_list):
         partner._fields_sync(vals)
         partner._handle_first_contact_creation()
     return partners
Example #19
0
    def write(self, vals):
        # First checks if user tries to modify moderation fields and has not the right to do it.
        if any(key for key in MODERATION_FIELDS if vals.get(key)) and any(self.env.user not in channel.moderator_ids for channel in self if channel.moderation):
            if not self.env.user.has_group('base.group_system'):
                raise UserError("You do not possess the rights to modify fields related to moderation on one of the channels you are modifying.")

        tools.image_resize_images(vals)
        result = super(Channel, self).write(vals)

        if vals.get('group_ids'):
            self._subscribe_users()

        # avoid keeping messages to moderate and accept them
        if vals.get('moderation') is False:
            self.env['mail.message'].search([
                ('moderation_status', '=', 'pending_moderation'),
                ('model', '=', 'mail.channel'),
                ('res_id', 'in', self.ids)
            ])._moderate_accept()

        return result
Example #20
0
    def create(self, vals):
        """ Store the initial standard price in order to be able to retrieve the cost of a product template for a given date"""
        # TDE FIXME: context brol
        tools.image_resize_images(vals)
        template = super(ProductTemplate, self).create(vals)
        if "create_product_product" not in self._context:
            template.create_variant_ids()

        # This is needed to set given values to first variant after creation
        related_vals = {}
        if vals.get("barcode"):
            related_vals["barcode"] = vals["barcode"]
        if vals.get("default_code"):
            related_vals["default_code"] = vals["default_code"]
        if vals.get("standard_price"):
            related_vals["standard_price"] = vals["standard_price"]
        if vals.get("volume"):
            related_vals["volume"] = vals["volume"]
        if vals.get("weight"):
            related_vals["weight"] = vals["weight"]
        if related_vals:
            template.write(related_vals)
        return template
Example #21
0
    def write(self, vals):
        if vals.get('active') is False:
            for partner in self:
                if partner.active and partner.user_ids:
                    raise ValidationError(_('You cannot archive a contact linked to an internal user.'))
        # res.partner must only allow to set the company_id of a partner if it
        # is the same as the company of all users that inherit from this partner
        # (this is to allow the code from res_users to write to the partner!) or
        # if setting the company_id to False (this is compatible with any user
        # company)
        if vals.get('website'):
            vals['website'] = self._clean_website(vals['website'])
        if vals.get('parent_id'):
            vals['company_name'] = False
        if vals.get('company_id'):
            company = self.env['res.company'].browse(vals['company_id'])
            for partner in self:
                if partner.user_ids:
                    companies = set(user.company_id for user in partner.user_ids)
                    if len(companies) > 1 or company not in companies:
                        raise UserError(
                            ("The selected company is not compatible with the companies of the related user(s)"))
        # no padding on the big image, because it's used as website logo
        tools.image_resize_images(vals, return_big=False)
        tools.image_resize_images(vals, return_medium=False, return_small=False)

        result = True
        # To write in SUPERUSER on field is_company and avoid access rights problems.
        if 'is_company' in vals and self.user_has_groups('base.group_partner_manager') and not self.env.uid == SUPERUSER_ID:
            result = super(Partner, self.sudo()).write({'is_company': vals.get('is_company')})
            del vals['is_company']
        result = result and super(Partner, self).write(vals)
        for partner in self:
            if any(u.has_group('base.group_user') for u in partner.user_ids if u != self.env.user):
                self.env['res.users'].check_access_rights('write')
            partner._fields_sync(vals)
        return result
Example #22
0
File: hr.py Project: befks/odoo
 def create(self, vals):
     if vals.get('user_id'):
         vals.update(self._sync_user(self.env['res.users'].browse(vals['user_id'])))
     tools.image_resize_images(vals)
     return super(Employee, self).create(vals)
 def write(self, vals):
     tools.image_resize_images(vals,
                               big_name='custom_thumbnail',
                               medium_name='custom_thumbnail_medium',
                               small_name='custom_thumbnail_small')
     return super(Thumbnail, self).write(vals)
Example #24
0
 def write(self, vals):
     tools.image_resize_images(vals)
     result = super(Channel, self).write(vals)
     if vals.get('group_ids'):
         self._subscribe_users()
     return result
Example #25
0
 def create(self, vals):
     if not vals.get('image'):
         vals['image'] = self._default_image()
     tools.image_resize_images(vals)
     return super(Repository, self).create(vals)
Example #26
0
File: badge.py Project: Vauxoo/odoo
 def create(self, values_list):
     for vals in values_list:
         tools.image_resize_images(vals)
     return super(GamificationBadge, self).create(values_list)
Example #27
0
 def create(self, vals_list):
     for vals in vals_list:
         tools.image_resize_images(vals)
     res = super(PopsProductBrand, self).create(vals_list)
     return res
Example #28
0
 def write(self, vals):
     image_resize_images(vals)
     vals = self._check_journal_id(vals)
     return super(PaymentAcquirer, self).write(vals)
Example #29
0
    def write(self, vals):
        if vals.get('shop_markup'):
            old_markup = self.shop_markup
            markup = vals.get('shop_markup')
            for rec in self:
                prod_tmpl_obj = self.env['product.template'].with_context(
                    {'collection_mark': 'collected'})
                prod_prod_obj = self.env['product.product'].with_context(
                    {'collection_mark': 'collected'})
                prod_attr_price_obj = self.env['product.attribute.price'].sudo(
                )
                # 更新店铺中收录的产品
                shop_prods = prod_tmpl_obj.search([('product_owner', '=',
                                                    rec.id)])
                if shop_prods:
                    mod_time = fields.Datetime.now()
                    for s_prod in shop_prods:
                        s_prod.list_price = s_prod.list_price / (
                            1 + old_markup / 100.0) * (1 + markup / 100.0)

                        s_attr_val = s_prod.mapped('attribute_line_ids')
                        for value in s_attr_val:
                            vlu = value[0].id
                            s_attr_price = prod_attr_price_obj.search([
                                ('product_tmpl_id', '=', s_prod.id),
                                ('value_id', '=', vlu)
                            ])
                            if s_attr_price:
                                s_attr_price.write({
                                    'price_extra':
                                    s_attr_price.price_extra /
                                    (1 + old_markup / 100.0) *
                                    (1 + markup / 100.0)
                                })
                        for prod in prod_prod_obj.search([('product_tmpl_id',
                                                           '=', s_prod.id)]):
                            prod._set_product_lst_price()
                            prod.write({
                                'price_update': 'pending',
                                'price_mod_time': mod_time
                            })
        ##########################################################################
        # res.partner must only allow to set the company_id of a partner if it
        # is the same as the company of all users that inherit from this partner
        # (this is to allow the code from res_users to write to the partner!) or
        # if setting the company_id to False (this is compatible with any user
        # company)
        if vals.get('website'):
            vals['website'] = self._clean_website(vals['website'])
        if vals.get('parent_id'):
            vals['company_name'] = False
        if vals.get('company_id'):
            company = self.env['res.company'].browse(vals['company_id'])
            for partner in self:
                if partner.user_ids:
                    companies = set(user.company_id
                                    for user in partner.user_ids)
                    if len(companies) > 1 or company not in companies:
                        raise UserError(
                            _("You can not change the company as the partner/user has multiple user linked with different companies."
                              ))
        tools.image_resize_images(vals)

        result = True
        # To write in SUPERUSER on field is_company and avoid access rights problems.
        if 'is_company' in vals and self.user_has_groups(
                'base.group_partner_manager'
        ) and not self.env.uid == SUPERUSER_ID:
            result = super(b2b_partner, self).sudo().write(
                {'is_company': vals.get('is_company')})
            del vals['is_company']
        result = result and super(b2b_partner, self).write(vals)
        for partner in self:
            if any(
                    u.has_group('base.group_user') for u in partner.user_ids
                    if u != self.env.user):
                self.env['res.users'].check_access_rights('write')
            partner._fields_sync(vals)
        return result
Example #30
0
 def create(self, vals):
     if vals.get('user_id'):
         vals.update(self._sync_user(self.env['res.users'].browse(vals['user_id'])))
     tools.image_resize_images(vals)
     return super(Employee, self).create(vals)
Example #31
0
 def write(self, vals):
     image_resize_images(vals)
     return super(PaymentAcquirer, self).write(vals)
Example #32
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(ImLivechatChannel, self).write(vals)
Example #33
0
 def write(self, vals):
     tools.image_resize_images(vals)
     result = super(Channel, self).write(vals)
     if vals.get('group_ids'):
         self._subscribe_users()
     return result
Example #34
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(ProductPublicCategory, self).write(vals)
Example #35
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(FleetVehicleModelBrand, self).write(vals)
Example #36
0
 def create(self, vals):
     tools.image_resize_images(vals)
     return super(Mentor, self).create(vals)
Example #37
0
 def write(self, vals):
     tools.image_resize_images(vals)
     lot = super(BtAsset, self).write(vals)
     return lot
Example #38
0
 def create(self, vals):
     tools.image_resize_images(vals)
     vals.update({'is_created':True})
     lot = super(BtAsset, self).create(vals)
     lot.message_post(body=_("Asset %s created with asset code %s")% (lot.name,lot.asset_code))
     return lot
Example #39
0
 def write(self, vals):
     tools.image_resize_images(vals)
     res = super(PopsProductBrand, self).write(vals)
     return res
Example #40
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(GenericLocation, self).write(vals)
Example #41
0
File: badge.py Project: Vauxoo/odoo
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(GamificationBadge, self).write(vals)
Example #42
0
 def write(self, vals):
     """ render image size """
     tools.image_resize_images(vals)
     res = super(CarType, self).write(vals)
     return res
Example #43
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(Repository, self).write(vals)
Example #44
0
 def write(self, vals):
     """ render image size """
     tools.image_resize_images(vals)
     res = super(SubFormTemplateLine, self).write(vals)
     return res
Example #45
0
 def write(self, vals):
     image_resize_images(vals)
     vals = self._check_journal_id(vals)
     return super(PaymentAcquirer, self).write(vals)
Example #46
0
 def write(self, vals):
     """ render image size """
     tools.image_resize_images(vals)
     res = super(VendorDashboardLine, self).write(vals)
     return res
Example #47
0
    def write(self, values):
        tools.image_resize_images(values)
        res = super().write(values)

        return res
Example #48
0
 def create(self, vals):
     """ render image size """
     tools.image_resize_images(vals)
     res = super(VendorDashboard, self).create(vals)
     return res
Example #49
0
    def create(self, values):
        tools.image_resize_images(values)
        res = super().create(values)

        return res
Example #50
0
 def _before_write(self, vals, *largs, **kwargs):
     tools.image_resize_images(vals,
                               big_name='custom_thumbnail',
                               medium_name='custom_thumbnail_medium',
                               small_name='custom_thumbnail_small')
     return super(File, self)._before_write(vals, *largs, **kwargs)
Example #51
0
 def create(self, vals_list):
     for vals in vals_list:
         tools.image_resize_images(vals)
     return super(FleetVehicleModelBrand, self).create(vals_list)
Example #52
0
 def write(self, vals):
     tools.image_resize_images(vals, big_name='image')
     return super(Product, self).write(vals)
Example #53
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(Employee, self).write(vals)
Example #54
0
 def create(self, vals):
     tools.image_resize_images(vals,
                               big_name='image',
                               medium_name='image_medium',
                               small_name='image_small')
     return super(Product, self).create(vals)
Example #55
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(Employee, self).write(vals)
Example #56
0
 def create(self, vals):
     tools.image_resize_images(vals)
     return super(traineemodel, self).create(vals)
Example #57
0
 def write(self, vals):
     tools.image_resize_images(vals)
     res = super(LibraryBook, self).write(vals)
     return res
Example #58
0
 def write(self, vals):
     image_resize_images(vals)
     return super(HrPropertyName, self).write(vals)
Example #59
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(ProductPublicCategory, self).write(vals)
Example #60
0
 def write(self, vals):
     tools.image_resize_images(vals)
     return super(AssetManagementAsset, self).write(vals)