Beispiel #1
0
    def write(self, vals):
        search_domain = False  # Overtime to generate
        delete_domain = False  # Overtime to delete

        overtime_enabled_companies = self.filtered('hr_attendance_overtime')
        # Prevent any further logic if we are disabling the feature
        is_disabling_overtime = False
        # If we disable overtime
        if 'hr_attendance_overtime' in vals and not vals[
                'hr_attendance_overtime'] and overtime_enabled_companies:
            delete_domain = [('company_id', 'in',
                              overtime_enabled_companies.ids)]
            vals['overtime_start_date'] = False
            is_disabling_overtime = True

        start_date = vals.get('hr_attendance_overtime') and vals.get(
            'overtime_start_date')
        # Also recompute if the threshold have changed
        if not is_disabling_overtime and (
                start_date or 'overtime_company_threshold' in vals
                or 'overtime_employee_threshold' in vals):
            for company in self:
                # If we modify the thresholds only
                if start_date == company.overtime_start_date and \
                    (vals.get('overtime_company_threshold') != company.overtime_company_threshold) or\
                    (vals.get('overtime_employee_threshold') != company.overtime_employee_threshold):
                    search_domain = OR([
                        search_domain,
                        [('employee_id.company_id', '=', company.id)]
                    ])
                # If we enabled the overtime with a start date
                elif not company.overtime_start_date and start_date:
                    search_domain = OR([
                        search_domain,
                        [('employee_id.company_id', '=', company.id),
                         ('check_in', '>=', start_date)]
                    ])
                # If we move the start date into the past
                elif start_date and company.overtime_start_date > start_date:
                    search_domain = OR([
                        search_domain,
                        [('employee_id.company_id', '=', company.id),
                         ('check_in', '>=', start_date),
                         ('check_in', '<=', company.overtime_start_date)]
                    ])
                # If we move the start date into the future
                elif start_date and company.overtime_start_date < start_date:
                    delete_domain = OR([
                        delete_domain,
                        [('company_id', '=', company.id),
                         ('date', '<', start_date)]
                    ])

        res = super().write(vals)
        if delete_domain:
            self.env['hr.attendance.overtime'].search(delete_domain).unlink()
        if search_domain:
            self.env['hr.attendance'].search(search_domain)._update_overtime()

        return res
Beispiel #2
0
    def _company_monthly_invoicing_today(self):
        """Get company ids for which today is monthly invoicing day."""
        today = datetime.now()
        first_day_this_month = today.replace(
            day=1, hour=0, minute=0, second=0, microsecond=0
        )
        first_day_last_month = first_day_this_month - relativedelta(months=1)
        last_day_of_this_month = (today + relativedelta(day=31)).day
        # Last month still not executed, it needs to be done
        domain_last_month = [
            ("invoicing_mode_monthly_last_execution", "<", first_day_last_month),
        ]
        # Invoicing day is today or in the past and invoicing not yet done
        domain_this_month = [
            "|",
            ("invoicing_mode_monthly_last_execution", "<", first_day_this_month),
            ("invoicing_mode_monthly_last_execution", "=", False),
            ("invoicing_mode_monthly_day_todo", "<=", today.day),
        ]
        # Make sure non exisiting days are done at the end of the month
        domain_last_day_of_month = [
            "|",
            ("invoicing_mode_monthly_last_execution", "<", first_day_this_month),
            ("invoicing_mode_monthly_last_execution", "=", False),
            ("invoicing_mode_monthly_day_todo", ">", today.day),
        ]
        if today.day == last_day_of_this_month:
            domain = OR(
                [domain_last_month, domain_this_month, domain_last_day_of_month]
            )
        else:
            domain = OR([domain_last_month, domain_this_month])

        return self.env["res.company"].search(domain)
Beispiel #3
0
    def my_members(self, page=1, sortby=None, search=None, search_in='name', **kw):
        members = request.env['res.partner']
        domain = [
            ('upline', '=', request.env.user.partner_id.id)
        ]

        searchbar_sortings = {
            'ref': {'label': _('Member Id'), 'order': 'ref desc'},
            'name': {'label': _('Name'), 'order': 'name'},
            'status': {'label': _('Status'), 'order': 'status'},
            'join_date': {'label': _('Join Date'), 'order': 'join_date'},
        }

        searchbar_inputs = {
            'all': {'input': 'all', 'label': _('Search in All')},
            'name': {'input': 'name', 'label': _('Name')},
            'ref': {'input': 'ref', 'label': _('Member ID')},
            'status': {'input': 'status', 'label': _('Status')},
            'region': {'input': 'region', 'label': _('Region')},
        }

        if search and search_in:
            search_domain = []
            if search_in in ('name', 'all'):
                search_domain = OR([search_domain, ['|', ('name', 'ilike', search), ('display_name', 'ilike', search)]])
            if search_in in ('ref', 'all'):
                search_domain = OR([search_domain, [('ref', 'ilike', search)]])
            if search_in in ('status', 'all'):
                search_domain = OR([search_domain, [('status', 'ilike', search)]])
            if search_in in ('region', 'all'):
                search_domain = OR([search_domain, [('state_id.name', 'ilike', search)]])
            domain += search_domain

        if not sortby:
            sortby = 'join_date'
        sort_order = searchbar_sortings[sortby]['order']
        order_count = members.sudo().search_count(domain)
        pager = portal_pager(
            url="/my/downline",
            url_args={'sortby': sortby},
            total=order_count,
            page=page,
            step=25
        )
        members = members.sudo().search(domain, order=sort_order, limit=25, offset=pager['offset'])
        request.session['my_member_history'] = members.ids[:100]
        values = {
            'page_display_name': 'Downline',
            'page_name': "downline",
            'members': members,
            'pager': pager,
            'default_url': '/my/downline',
            'searchbar_sortings': searchbar_sortings,
            'searchbar_inputs': searchbar_inputs,
            'sortby': sortby,
            'search_in': search_in,
            'search': search,
        }
        return request.render('inuka_customer_portal.members_page', values)
    def check_existing(self, vals):
        """Check wether records exist that do not fit new criteria."""
        relation_model = self.env['res.partner.relation']

        def get_type_condition(vals, side):
            """Add if needed check for contact type."""
            fieldname1 = 'contact_type_%s' % side
            fieldname2 = '%s_partner_id.is_company' % side
            contact_type = fieldname1 in vals and vals[fieldname1] or False
            if contact_type == 'c':
                # Records that are not companies are invalid:
                return [(fieldname2, '=', False)]
            if contact_type == 'p':
                # Records that are companies are invalid:
                return [(fieldname2, '=', True)]
            return []

        def get_category_condition(vals, side):
            """Add if needed check for partner category."""
            fieldname1 = 'partner_category_%s' % side
            fieldname2 = '%s_partner_id.category_id' % side
            category_id = fieldname1 in vals and vals[fieldname1] or False
            if category_id:
                # Records that do not have the specified category are invalid:
                return [(fieldname2, 'not in', [category_id])]
            return []

        for this in self:
            handling = ('handle_invalid_onchange' in vals
                        and vals['handle_invalid_onchange']
                        or this.handle_invalid_onchange)
            if handling == 'ignore':
                continue
            invalid_conditions = []
            for side in ['left', 'right']:
                invalid_conditions = OR([
                    invalid_conditions,
                    get_type_condition(vals, side),
                ])
                invalid_conditions = OR([
                    invalid_conditions,
                    get_category_condition(vals, side),
                ])
            if not invalid_conditions:
                return
            # only look at relations for this type
            invalid_domain = AND([[('type_id', '=', this.id)],
                                  invalid_conditions])
            invalid_relations = relation_model.with_context(
                active_test=False).search(invalid_domain)
            if invalid_relations:
                if handling == 'restrict':
                    raise ValidationError(
                        _('There are already relations not satisfying the'
                          ' conditions for partner type or category.'))
                elif handling == 'delete':
                    invalid_relations.unlink()
                else:
                    self._end_active_relations(invalid_relations)
    def check_existing(self, vals):
        """Check wether records exist that do not fit new criteria."""
        relation_model = self.env["res.partner.relation"]

        def get_type_condition(vals, side):
            """Add if needed check for contact type."""
            fieldname1 = "contact_type_%s" % side
            fieldname2 = "%s_partner_id.is_company" % side
            contact_type = fieldname1 in vals and vals[fieldname1] or False
            if contact_type == "c":
                # Records that are not companies are invalid:
                return [(fieldname2, "=", False)]
            if contact_type == "p":
                # Records that are companies are invalid:
                return [(fieldname2, "=", True)]
            return []

        def get_category_condition(vals, side):
            """Add if needed check for partner category."""
            fieldname1 = "partner_category_%s" % side
            fieldname2 = "%s_partner_id.category_id" % side
            category_id = fieldname1 in vals and vals[fieldname1] or False
            if category_id:
                # Records that do not have the specified category are invalid:
                return [(fieldname2, "not in", [category_id])]
            return []

        for this in self:
            handling = ("handle_invalid_onchange" in vals
                        and vals["handle_invalid_onchange"]
                        or this.handle_invalid_onchange)
            if handling == "ignore":
                continue
            invalid_conditions = []
            for side in ["left", "right"]:
                invalid_conditions = OR(
                    [invalid_conditions,
                     get_type_condition(vals, side)])
                invalid_conditions = OR(
                    [invalid_conditions,
                     get_category_condition(vals, side)])
            if not invalid_conditions:
                return
            # only look at relations for this type
            invalid_domain = AND([[("type_id", "=", this.id)],
                                  invalid_conditions])
            invalid_relations = relation_model.with_context(
                active_test=False).search(invalid_domain)
            if invalid_relations:
                if handling == "restrict":
                    raise ValidationError(
                        _("There are already relations not satisfying the"
                          " conditions for partner type or category."))
                elif handling == "delete":
                    invalid_relations.unlink()
                else:
                    self._end_active_relations(invalid_relations)
Beispiel #6
0
    def get_private_address_access_domain(self):
        domain = super().get_private_address_access_domain()

        if self.env.user.has_internal_employee_access():
            domain = OR((domain, [("employee_type", "=", "internal")]))

        if self.env.user.has_external_employee_access():
            domain = OR((domain, [("employee_type", "=", "external")]))

        return domain
Beispiel #7
0
 def _get_search_domain(self, search_in, search):
     search_domain = []
     if search_in in ('project', 'all'):
         search_domain = OR([search_domain, [('project_id', 'ilike', search)]])
     if search_in in ('name', 'all'):
         search_domain = OR([search_domain, [('name', 'ilike', search)]])
     if search_in in ('employee', 'all'):
         search_domain = OR([search_domain, [('employee_id', 'ilike', search)]])
     if search_in in ('task', 'all'):
         search_domain = OR([search_domain, [('task_id', 'ilike', search)]])
     return search_domain
 def _search_relation_type_id(self, operator, value):
     """Search partners based on their type of relations."""
     result = []
     if operator not in SUPPORTED_OPERATORS:
         raise exceptions.ValidationError(
             _('Unsupported search operator "%s"') % operator)
     type_selection_model = self.env["res.partner.relation.type.selection"]
     relation_type_selection = []
     if operator == "=" and isinstance(value, numbers.Integral):
         relation_type_selection += type_selection_model.browse(value)
     elif operator == "!=" and isinstance(value, numbers.Integral):
         relation_type_selection = type_selection_model.search([
             ("id", operator, value)
         ])
     else:
         relation_type_selection = type_selection_model.search([
             "|",
             ("type_id.name", operator, value),
             ("type_id.name_inverse", operator, value),
         ])
     if not relation_type_selection:
         result = [FALSE_LEAF]
     for relation_type in relation_type_selection:
         result = OR([
             result,
             [("relation_all_ids.type_selection_id.id", "=",
               relation_type.id)],
         ])
     return result
Beispiel #9
0
    def action_open_actual_replenishment_details(self, date_str, date_start, date_stop):
        """ Open the actual replenishment details.

        :param date_str: period name for the forecast sellected
        :param date_start: select incoming moves and RFQ after this date
        :param date_stop: select incoming moves and RFQ before this date
        :return: action values that open the forecast details wizard
        :rtype: dict
        """
        domain_confirm, domain_done = self._get_moves_domain(date_start, date_stop, 'incoming')
        move_ids = self.env['stock.move'].search(OR([domain_confirm, domain_done])).ids

        rfq_domain = self._get_rfq_domain(date_start, date_stop)
        purchase_order_line_ids = self.env['purchase.order.line'].search(rfq_domain).ids
        name = _('Actual Replenishment %s %s (%s - %s)') % (self.product_id.display_name, date_str, date_start, date_stop)

        context = {
            'default_move_ids': move_ids,
            'default_purchase_order_line_ids': purchase_order_line_ids,
            'action_name': name,
        }
        return {
            'type': 'ir.actions.act_window',
            'name': name,
            'view_mode': 'form',
            'res_model': 'mrp.mps.forecast.details',
            'views': [(False, 'form')],
            'target': 'new',
            'context': context
        }
Beispiel #10
0
 def _task_get_search_domain(self, search_in, search):
     search_domain = []
     if search_in in ('content', 'all'):
         search_domain.append([('name', 'ilike', search)])
         search_domain.append([('description', 'ilike', search)])
     if search_in in ('customer', 'all'):
         search_domain.append([('partner_id', 'ilike', search)])
     if search_in in ('message', 'all'):
         search_domain.append([('message_ids.body', 'ilike', search)])
     if search_in in ('stage', 'all'):
         search_domain.append([('stage_id', 'ilike', search)])
     if search_in in ('project', 'all'):
         search_domain.append([('project_id', 'ilike', search)])
     if search_in in ('ref', 'all'):
         search_domain.append([('id', 'ilike', search)])
     if search_in in ('users', 'all'):
         user_ids = request.env['res.users'].sudo().search([('name', 'ilike', search)])
         search_domain.append([('user_ids', 'in', user_ids.ids)])
     if search_in in ('priority', 'all'):
         search_domain.append([('priority', 'ilike', search == 'normal' and '0' or '1')])
     if search_in in ('status', 'all'):
         search_domain.append([
             ('kanban_state', 'ilike', 'normal' if search == 'In Progress' else 'done' if search == 'Ready' else 'blocked' if search == 'Blocked' else search)
         ])
     return OR(search_domain)
Beispiel #11
0
    def _get_domain_search_name(self, term):

        name_field, operator, search_name = term

        if name_field not in ('name', 'display_name'):
            return [term]
        if not search_name:
            return [term]
        if operator not in ('=', 'ilike', '=ilike', 'like', '=like'):
            return [term]
#        if ' ' not in search_name:
#            return [term]
# else

        parts = search_name.split(' ')
        search_fields = (
            'name',
            'display_name',
            'email',
            'city',
            'street',
        )
        return AND([
            OR([(f, operator, part)] for f in search_fields) for part in parts
        ], )
Beispiel #12
0
    def _compute_component_ids(self):
        self.component_ids = False
        points = self.filtered(
            lambda p: p.is_workorder_step and p.test_type in
            ['register_consumed_materials', 'register_byproducts'])
        bom_domain = OR([
            self.env['mrp.bom']._bom_find_domain(product=product._origin)
            for product in points.product_ids
        ])
        bom_ids = self.env['mrp.bom'].search(bom_domain)
        product_by_points = defaultdict(lambda: self.env['quality.point'])
        for point in points:
            for product in point.product_ids:
                product_by_points[product._origin] |= point

        for bom in bom_ids:
            bom_products = bom.product_id or bom.product_tmpl_id.product_variant_ids
            byproducts = bom.byproduct_ids.product_id
            for product in bom_products:
                if product not in product_by_points:
                    continue
                dummy, lines_done = bom.explode(product, 1.0)
                components = self.env['product.product'].browse(
                    [line[0].product_id.id for line in lines_done])
            for point in product_by_points[product]:
                if point.test_type == 'register_consumed_materials':
                    point.component_ids |= components
                else:
                    point.component_ids |= byproducts
Beispiel #13
0
    def portal_my_consigment_products(self, page=1, filterby=None, sortby=None, search=None, search_in='content', **kw):
#         response = super(CustomerPortal, self)
        values = self._prepare_portal_layout_values()
        product_obj = http.request.env['product.product']
        domain = [
            ('purchase_order_line_id', '!=', False)
        ]
        searchbar_filters = {
            'all': {'label': _('All'), 'domain': []},
        }
        if not filterby:
            filterby = 'all'
        domain += searchbar_filters[filterby]['domain']
        searchbar_inputs = {
            'content': {'input': 'content', 'label': _('Search <span class="nolabel"> (in Content)</span>')},
            'name': {'input': 'name', 'label': _('Search in Name')},
            'default_code': {'input': 'default_code', 'label': _('Search in Internal Reference')},
        }
        if search and search_in:
            search_domain = []
            if search_in in ('name', 'all'):
                search_domain = OR([search_domain, [('name', 'ilike', search)]])
            if search_in in ('default_code', 'all'):
                search_domain = OR([search_domain, [('default_code','ilike',search)]])
            domain += search_domain
        # count for pager
        consignment_product_count = product_obj.sudo().search_count(domain)
        # pager
        pager = portal_pager(
            url="/my/consignment_product_list",
            url_args={'sortby': sortby,'filterby': filterby},
            total=consignment_product_count,
            page=page,
            step=self._items_per_page
        )
        # content according to pager and archive selected
        consignment_products = product_obj.sudo().search(domain, limit=self._items_per_page, offset=pager['offset'])
        values.update({
            'consignment_products': consignment_products,
            'page_name': 'consignment_product_page',
            'searchbar_inputs': searchbar_inputs,
            'search_in': search_in,
            'filterby': filterby,
            'pager': pager,
            'default_url': '/my/consignment_product_list',
        })
        return request.render("odoo_consignment_process.display_consignment_product", values)
Beispiel #14
0
 def _loader_params_product_product(self):
     result = super()._loader_params_product_product()
     if self.config_id.use_gift_card and self.config_id.gift_card_product_id:
         result['search_params']['domain'] = OR([
             result['search_params']['domain'],
             [('id', '=', self.config_id.gift_card_product_id.id)]
         ])
     return result
Beispiel #15
0
 def _loader_params_product_product(self):
     result = super()._loader_params_product_product()
     result['search_params']['domain'] = OR([
         result['search_params']['domain'],
         [('id', '=', self.config_id.down_payment_product_id.id)]
     ])
     result['search_params']['fields'].extend(['invoice_policy', 'type'])
     return result
Beispiel #16
0
    def portal_my_tasks_prepare_task_search_domain(self, search_in, search):
        domain = super(CustomerPortal, self)\
            .portal_my_tasks_prepare_task_search_domain(search_in, search)

        if search and search_in:
            if search_in in ('content', 'all'):
                domain = OR([domain, [('key', 'ilike', search)]])
        return domain
    def _fields_view_get_add_exclusive_selection_attrs(self, doc):
        """Make the readonly and required attrs dynamic for putaway rules

        By default, product_id and category_id fields have static domains
        such as they are mutually exclusive: both fields are required,
        as soon as we select a product, the category becomes readonly and
        not required, if we select a category, the product becomes readonly
        and not required.

        If we add a third field, such as "route_id", the domains for the
        readonly and required attrs should now include "route_id" as well,
        and if we add a fourth field, again. We can't extend them this way
        from XML, so this method dynamically generate these domains and
        set it on the fields attrs.

        The only requirement is to have exclusive_selection set in the options
        of the field:

        ::

            <field name="route_id"
                options="{'no_create': True, 'no_open': True,
                          'exclusive_selection': True}"
                readonly="context.get('putaway_route', False)"
                force_save="1"
            />

        Look in module stock_putaway_by_route (where this is tested as well).
        """
        exclusive_fields = set()
        nodes = doc.xpath("//field[@options]")
        for field in nodes:
            options = safe_eval(field.attrib.get("options", "{}"))
            if options.get("exclusive_selection"):
                exclusive_fields.add(field)

        for field in exclusive_fields:
            readonly_domain = OR([[(other.attrib["name"], "!=", False)]
                                  for other in exclusive_fields
                                  if other != field])
            required_domain = AND([[(other.attrib["name"], "=", False)]
                                   for other in exclusive_fields
                                   if other != field])

            if field.attrib.get("attrs"):
                attrs = safe_eval(field.attrib["attrs"])
            else:
                attrs = {}
            attrs["readonly"] = readonly_domain
            attrs["required"] = required_domain

            field.set("attrs", str(attrs))
            modifiers = {}
            transfer_node_to_modifiers(field,
                                       modifiers,
                                       self.env.context,
                                       in_tree_view=True)
            transfer_modifiers_to_node(modifiers, field)
Beispiel #18
0
 def _task_get_search_domain(self, search_in, search):
     search_domain = [super()._task_get_search_domain(search_in, search)]
     if search_in in ('sale_order', 'all'):
         search_domain.append([('sale_order_id.name', 'ilike', search)])
     if search_in in ('sale_line', 'all'):
         search_domain.append([('sale_line_id.name', 'ilike', search)])
     if search_in in ('invoice', 'all'):
         search_domain.append([('sale_order_id.invoice_ids.name', 'ilike', search)])
     return OR(search_domain)
Beispiel #19
0
    def portal_my_tasks_prepare_task_search_domain(self, search_in, search):
        domain = super(CustomerPortal,
                       self).portal_my_tasks_prepare_task_search_domain(
                           search_in, search)

        if search and search_in:
            if search_in in ("content", "all"):
                domain = OR([domain, [("key", "ilike", search)]])
        return domain
Beispiel #20
0
 def portal_my_dms(self,
                   sortby=None,
                   filterby=None,
                   search=None,
                   search_in="name",
                   **kw):
     values = self._prepare_portal_layout_values()
     searchbar_sortings = {
         "name": {
             "label": _("Name"),
             "order": "name asc"
         }
     }
     # default sortby br
     if not sortby:
         sortby = "name"
     sort_br = searchbar_sortings[sortby]["order"]
     # search
     searchbar_inputs = {
         "name": {
             "input": "name",
             "label": _("Name")
         },
     }
     if not filterby:
         filterby = "name"
     # domain
     domain = [(
         "id",
         "in",
         request.env["dms.directory"]._get_own_root_directories(
             request.env.user.id),
     )]
     # search
     if search and search_in:
         search_domain = []
         if search_in == "name":
             search_domain = OR(
                 [search_domain, [("name", "ilike", search)]])
         domain += search_domain
     # content according to pager and archive selected
     items = (request.env["dms.directory"].with_user(
         request.env.user.id).search(domain, order=sort_br))
     request.session["my_dms_folder_history"] = items.ids
     # values
     values.update({
         "dms_directories": items.sudo(),
         "page_name": "dms_directory",
         "default_url": "/my/dms",
         "searchbar_sortings": searchbar_sortings,
         "searchbar_inputs": searchbar_inputs,
         "search_in": search_in,
         "sortby": sortby,
         "filterby": filterby,
         "access_token": None,
     })
     return request.render("dms.portal_my_dms", values)
Beispiel #21
0
 def _loader_params_product_product(self):
     result = super(PosSession, self)._loader_params_product_product()
     config = self.config_id
     if config.all_program_ids:
         programs = config.all_program_ids
         rewards = programs.reward_ids
         products = (programs.rule_ids.valid_product_ids | rewards.discount_line_product_id) |\
             (rewards.all_discount_product_ids | rewards.reward_product_ids)
         result['search_params']['domain'] = OR([result['search_params']['domain'], [('id', 'in', products.ids)]])
     return result
    def _shipping_line_ids(self):
        line_cost_obj = self.env['line.cost']
        for rec in self:
            commodity_ids = rec.commodity_ids
            domain = [('country_loading_id', '=', rec.country_loading_id.id),
                      ('port_loading_id', '=', rec.port_loading_id.id),
                      ('port_dest_id', '=', rec.port_dest_id.id),
                      ('country_dest_id', '=', rec.country_dest_id.id),
                      ('line_cost_ids.sea_lines_id.type', '=',
                       rec.shipment_type), ('is_expired', '=', False)]
            domain = AND([
                domain,
                OR([[('customer_id', '=', rec.partner_id.id)],
                    [('customer_id', '=', False)]])
            ])

            domain = AND([
                domain,
                OR([[('commodity_id', 'in', commodity_ids.ids)],
                    [('fak', '=', True)]])
            ])

            if rec.is_loading:
                domain = AND([
                    domain,
                    AND([[('line_cost_ids.is_loading', '=', True),
                          ('place_loading_id', '=', rec.place_loading_id.id)],
                         OR([[('city_loading_id', '=', rec.city_loading_id.id)
                              ],
                             [('state_loading_id', '=',
                               rec.state_loading_id.id)]])])
                ])
            if rec.is_discharge:
                domain = AND([
                    domain,
                    AND([[('line_cost_ids.is_discharge', '=', True),
                          ('place_dest_id', '=', rec.place_dest_id.id)],
                         OR([[('city_dest_id', '=', rec.city_dest_id.id)],
                             [('state_dest_id', '=', rec.state_dest_id.id)]])])
                ])
            line_cost_ids = line_cost_obj.search(domain)
            rec.shipping_line_ids = [(6, 0, line_cost_ids.ids)]
Beispiel #23
0
 def _get_default_stage_id(self):
     """ Gives default stage_id """
     team_id = self.env.context.get('default_team_id')
     if not team_id and self.env.context.get('active_model') == 'quality.alert.team' and\
             self.env.context.get('active_id'):
         team_id = self.env['quality.alert.team'].browse(
             self.env.context.get('active_id')).exists().id
     domain = [('team_ids', '=', False)]
     if team_id:
         domain = OR([domain, [('team_ids', 'in', team_id)]])
     return self.env['quality.alert.stage'].search(domain, limit=1).id
Beispiel #24
0
 def portal_my_tasks_prepare_task_search_domain(self, search_in, search):
     search_domain = []
     if search and search_in:
         if search_in in ('content', 'all'):
             search_domain = OR([
                 search_domain,
                 [
                     '|', ('name', 'ilike', search),
                     ('description', 'ilike', search)
                 ]
             ])
         if search_in in ('customer', 'all'):
             search_domain = OR(
                 [search_domain, [('partner_id', 'ilike', search)]])
         if search_in in ('message', 'all'):
             search_domain = OR(
                 [search_domain, [('message_ids.body', 'ilike', search)]])
         if search_in in ('stage', 'all'):
             search_domain = OR(
                 [search_domain, [('stage_id', 'ilike', search)]])
     return search_domain
Beispiel #25
0
    def portal_my_tasks_prepare_task_search_domain(self, search_in, search):
        domain = super(CustomerPortal, self).\
            portal_my_tasks_prepare_task_search_domain(search_in, search)

        if search and search_in:
            if search_in in ('content', 'all'):
                domain = OR([domain, [
                    '|',
                    ('type_id', 'ilike', search),
                    ('priority_id', 'ilike', search)
                ]])
        return domain
Beispiel #26
0
    def action_view_purchase(self):
        """ This function returns an action that display existing
        purchase orders of given orderpoint.
        """
        result = super(StockWarehouseOrderpoint, self).action_view_purchase()
        if self.purchase_line_ids:
            order_ids = self.purchase_line_ids.mapped('order_id')
            result['domain'] = OR([ast.literal_eval(result['domain']),
                                   ast.literal_eval(
                                       "[('id','in',%s)]" % order_ids.ids)])

        return result
Beispiel #27
0
 def action_view_stock_valuation_layers(self):
     action = super(StockPicking, self).action_view_stock_valuation_layers()
     subcontracted_productions = self._get_subcontracted_productions()
     if not subcontracted_productions:
         return action
     domain = action['domain']
     domain_subcontracting = [
         ('id', 'in', (subcontracted_productions.move_raw_ids
                       | subcontracted_productions.move_finished_ids
                       ).stock_valuation_layer_ids.ids)
     ]
     domain = OR([domain, domain_subcontracting])
     return dict(action, domain=domain)
Beispiel #28
0
    def portal_my_consignment_pickings(self, page=1, filterby=None, sortby=None, search=None, search_in='content', **kw):
#         response = super(CustomerPortal, self)
        values = self._prepare_portal_layout_values()
        partner = request.env.user.partner_id
        picking_obj = http.request.env['stock.picking']
        domain = [
            ('owner_id', '=', partner.id),
            ('picking_type_code','=','incoming'),
            ('is_consignment','!=',False)
        ]
        # count for pager
        picking_count = picking_obj.sudo().search_count(domain)
        
        searchbar_filters = {
            'all': {'label': _('All'), 'domain': []},
        }
        
        if not filterby:
            filterby = 'all'
        domain += searchbar_filters[filterby]['domain']
        
        searchbar_inputs = {
            'content': {'input': 'content', 'label': _('Search <span class="nolabel"> (in Content)</span>')},
            'product_id': {'input': 'product_id', 'label': _('Search in Product')},
        }
        
        if search and search_in:
            search_domain = []
            if search_in in ('product_id', 'all'):
                search_domain = OR([search_domain, [('product_id', 'ilike', search)]])
            domain += search_domain
        # pager
        pager = portal_pager(
            url="/my/consignment_pickings",
            url_args={'sortby': sortby,'filterby': filterby},
            total=picking_count,
            page=page,
            step=self._items_per_page
        )
        # content according to pager and archive selected
        pickings = picking_obj.sudo().search(domain, limit=self._items_per_page, offset=pager['offset'])
        values.update({
            'pickings': pickings,
            'page_name': 'consignment_picking',
            'searchbar_inputs': searchbar_inputs,
            'search_in': search_in,
            'filterby': filterby,
            'pager': pager,
            'default_url': '/my/consignment_pickings',
        })
        return request.render("odoo_consignment_process.display_stock_pickings", values)
Beispiel #29
0
    def portal_my_tasks_prepare_task_search_domain(self, search_in, search):
        search_domain = []
        if search and search_in:
            if search_in in ("content", "all"):
                search_domain = OR([
                    search_domain,
                    [
                        "|",
                        ("name", "ilike", search),
                        ("description", "ilike", search),
                    ],
                ])

            if search_in in ("customer", "all"):
                search_domain = OR(
                    [search_domain, [("partner_id", "ilike", search)]])
            if search_in in ("message", "all"):
                search_domain = OR(
                    [search_domain, [("message_ids.body", "ilike", search)]])
            if search_in in ("stage", "all"):
                search_domain = OR(
                    [search_domain, [("stage_id", "ilike", search)]])
        return search_domain
Beispiel #30
0
 def _get_permission_domain(self, operator, value, operation):
     """Abstract logic for searching computed permission fields."""
     _self = self
     # HACK While computing ir.rule domain, you're always superuser, so if
     # you're superuser but `value` is an `int`, we can assume safely that
     # you're checking permissions for another user (see the corresponding
     # rules in `security.xml`)
     # TODO Remove hack in v13, where sudo() and with_user() differ?
     if self.env.uid == SUPERUSER_ID and isinstance(value, int):
         _self = self.sudo(value)
         value = bool(value)
     # Tricky one, to know if you want to search
     # positive or negative access
     positive = (operator not in NEGATIVE_TERM_OPERATORS) == bool(value)
     if _self.env.uid == SUPERUSER_ID:
         return TRUE_DOMAIN if positive else FALSE_DOMAIN
     # Obtain and combine domains
     result = OR([
         _self._get_domain_by_access_groups(operation),
         _self._get_domain_by_inheritance(operation),
     ])
     if not positive:
         result.insert(0, "!")
     return result