Ejemplo n.º 1
0
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        """
        Change funding pool domain in order to include MSF Private fund
        """
        if context is None:
            context = {}
        view = super(hq_entries_split, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
        fields = view['fields']
        if view_type=='form' and fields:
            if fields.get('line_ids') and fields.get('line_ids')['views']:
                # get the default PF and include into the domain for analytic_id
                try:
                    fp_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'analytic_distribution', 'analytic_account_msf_private_funds')[1]
                except ValueError:
                    fp_id = 0

                viewtemp = fields.get('line_ids')['views']
                arch = etree.fromstring(viewtemp['tree']['arch']) # the analytic_id is found in the line_ids, one level down
                fields = arch.xpath('field[@name="analytic_id"]')
                if fields:
                    fields[0].set('domain', "[('type', '!=', 'view'), ('state', '=', 'open'), ('category', '=', 'FUNDING'), '|', '&', ('cost_center_ids', '=', cost_center_id), ('tuple_destination', '=', (account_id, destination_id)), ('id', '=', %s)]" % fp_id)

                # Change Destination field
                dest_fields = arch.xpath('field[@name="destination_id"]')
                for field in dest_fields:
                    field.set('domain', "[('type', '!=', 'view'), ('state', '=', 'open'), ('category', '=', 'DEST'), ('destination_ids', '=', account_id)]")
                    viewtemp['tree']['arch'] = etree.tostring(arch)
        return view
Ejemplo n.º 2
0
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
        if not context:
            context = {}
        res = super(account_tax_line,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)

        fields=res.get('fields',{})
        if fields:
            if context.get('tax_group','')=='vat':
                if fields.get('ref'):
                    res['fields']['ref']['string'] = _('Invoice No')
            else:
                if fields.get('ref'):
                    res['fields']['ref']['string'] = _('WHT No')

        return res
Ejemplo n.º 3
0
    def fields_view_get(self,
                        cr,
                        uid,
                        view_id=None,
                        view_type='form',
                        context=None,
                        toolbar=False,
                        submenu=False):
        result = super(stock_change_product_qty,
                       self).fields_view_get(cr, uid, view_id, view_type,
                                             context, toolbar, submenu)
        product_id = context and context.get('active_id', False) or False

        if (context.get('active_model') == 'product.product') and product_id:
            prod_obj = self.pool.get('product.product').browse(cr,
                                                               uid,
                                                               product_id,
                                                               context=context)
            fields = result.get('fields', {})
            if fields and (prod_obj.track_production
                           == True) and (fields.get('prodlot_id')):
                result['fields']['prodlot_id']['required'] = True
            else:
                result['fields']['prodlot_id']['required'] = False
        return result
Ejemplo n.º 4
0
 def _get_default_base(self, cr, uid, fields, context=None):
     product_price_type_obj = self.pool.get('product.price.type')
     if fields.get('type') == 'purchase':
         product_price_type_ids = product_price_type_obj.search(
             cr, uid, [('field', '=', 'standard_price')], context=context)
     elif fields.get('type') == 'sale':
         product_price_type_ids = product_price_type_obj.search(
             cr, uid, [('field', '=', 'list_price')], context=context)
     else:
         return -1
     if not product_price_type_ids:
         return False
     else:
         pricetype = product_price_type_obj.browse(cr,
                                                   uid,
                                                   product_price_type_ids,
                                                   context=context)[0]
         return pricetype.id
Ejemplo n.º 5
0
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False):
        if not context:
            context = {}
        res = super(product_product,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar)
        if context.get('location'):
            location_info = self.pool.get('stock.location').browse(cr, uid, context['location'])
            fields=res.get('fields',{})
            if fields:
                if location_info.usage == 'supplier':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Receptions')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Received Qty')

                if location_info.usage == 'internal':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Stock')

                if location_info.usage == 'customer':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Deliveries')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Delivered Qty')

                if location_info.usage == 'inventory':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future P&L')
                    res['fields']['qty_available']['string'] = _('P&L Qty')

                if location_info.usage == 'procurement':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Qty')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Unplanned Qty')

                if location_info.usage == 'production':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Productions')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Produced Qty')

        return res
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        result = super(stock_change_product_qty, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
        product_id = context and context.get('active_id', False) or False

        if (context.get('active_model') == 'product.product') and product_id:
            prod_obj = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
            fields = result.get('fields', {})
            if fields and (prod_obj.track_production == True) and (fields.get('prodlot_id')):
                result['fields']['prodlot_id']['required'] =  True
            else:
                result['fields']['prodlot_id']['required'] = False
        return result
Ejemplo n.º 7
0
 def _default_get_mobile(self, cr, uid, fields, context=None):
     if context is None:
         context = {}
     partner_pool = self.pool.get('res.partner')
     active_ids = fields.get('active_ids')
     res = {}
     i = 0
     for partner in partner_pool.browse(cr, uid, active_ids, context=context): 
         i += 1           
         res = partner.mobile
     if i > 1:
         raise orm.except_orm(_('Error'), _('You can only select one partner'))
     return res
Ejemplo n.º 8
0
    def fields_view_get(self, cr, uid, view_id=None, view_type="form", context=None, toolbar=False, submenu=False):
        result = super(stock_change_product_qty, self).fields_view_get(
            cr, uid, view_id, view_type, context, toolbar, submenu
        )
        product_id = context and context.get("active_id", False) or False

        if (context.get("active_model") == "product.product") and product_id:
            prod_obj = self.pool.get("product.product").browse(cr, uid, product_id, context=context)
            fields = result.get("fields", {})
            if fields and (prod_obj.track_production == True) and (fields.get("prodlot_id")):
                result["fields"]["prodlot_id"]["required"] = True
            else:
                result["fields"]["prodlot_id"]["required"] = False
        return result
Ejemplo n.º 9
0
    def fields_view_get(self,
                        cr,
                        uid,
                        view_id=None,
                        view_type='form',
                        context=None,
                        toolbar=False,
                        submenu=False):
        if not context:
            context = {}
        res = super(account_tax_line,
                    self).fields_view_get(cr, uid, view_id, view_type, context,
                                          toolbar, submenu)

        fields = res.get('fields', {})
        if fields:
            if context.get('tax_group', '') == 'vat':
                if fields.get('ref'):
                    res['fields']['ref']['string'] = _('Invoice No')
            else:
                if fields.get('ref'):
                    res['fields']['ref']['string'] = _('WHT No')

        return res
Ejemplo n.º 10
0
 def _get_domain(self, cr, uid, fields, context=None):
     values = ()
     where = ""
     query = "select distinct employee_id from hr_gp_contractframe "
     etab = fields['etab']
     date_start = fields['date_start']
     date_end = fields['date_end']
     activity = fields.get('activity_id', False)
     if etab and not activity:
         where = "where activity in (select id from hr_gp_activity where establishment=%s) and date_begin<=%s and date_end>=%s"
         values = (etab, date_end, date_start)
     elif etab and activity:
         where = "where activity=%s and date_begin<=%s and date_end>=%s"
         values = (activity, date_end, date_start)
     cr.execute(query + where, values)
     return [('id', 'in', [r[0] for r in cr.fetchall()])]
Ejemplo n.º 11
0
    def _get_briefs(self, cr, uid, ids, field_name, field_value, arg, context=None):
        record = self.browse(cr, uid, ids, context=context)[0]
        search_str = re.sub("\s*\n\s*", ' ', record.name.strip())
        result = {}
        brief_obj = self.pool.get('brief.main')

        fields = brief_obj.fields_get(cr, uid, [])
        states = []

        for s in fields.get('state')['selection']:
            if search_str.lower() in s[1].lower():
                states.append(s[0])

        args = ['|', '|', '|', ('state', 'in', states), ('notes', 'ilike', search_str), ('comment_mp', 'ilike', search_str), ('web_sites', 'ilike', search_str)]

        briefs = brief_obj.search(cr, uid, args)
        result[record.id] = briefs
        return result
Ejemplo n.º 12
0
    def fields_view_get(self, cr, uid, view_id=None, view_type="form", context=None, toolbar=False, submenu=False):
        journal_pool = self.pool.get("account.journal")
        if context is None:
            context = {}
        result = super(account_move_line, self).fields_view_get(
            cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu
        )
        if view_type != "tree":
            # Remove the toolbar from the form view
            if view_type == "form":
                if result.get("toolbar", False):
                    result["toolbar"]["action"] = []
            # Restrict the list of journal view in search view
            if view_type == "search" and result["fields"].get("journal_id", False):
                result["fields"]["journal_id"]["selection"] = journal_pool.name_search(cr, uid, "", [], context=context)
                ctx = context.copy()
                # we add the refunds journal in the selection field of journal
                if context.get("journal_type", False) == "sale":
                    ctx.update({"journal_type": "sale_refund"})
                    result["fields"]["journal_id"]["selection"] += journal_pool.name_search(
                        cr, uid, "", [], context=ctx
                    )
                elif context.get("journal_type", False) == "purchase":
                    ctx.update({"journal_type": "purchase_refund"})
                    result["fields"]["journal_id"]["selection"] += journal_pool.name_search(
                        cr, uid, "", [], context=ctx
                    )
            return result
        if context.get("view_mode", False):
            return result
        fld = []
        fields = {}
        flds = []
        title = _("Accounting Entries")  # self.view_header_get(cr, uid, view_id, view_type, context)

        ids = journal_pool.search(cr, uid, [])
        journals = journal_pool.browse(cr, uid, ids, context=context)
        all_journal = [None]
        common_fields = {}
        total = len(journals)
        for journal in journals:
            all_journal.append(journal.id)
            for field in journal.view_id.columns_id:
                if not field.field in fields:
                    fields[field.field] = [journal.id]
                    fld.append((field.field, field.sequence))
                    flds.append(field.field)
                    common_fields[field.field] = 1
                else:
                    fields.get(field.field).append(journal.id)
                    common_fields[field.field] = common_fields[field.field] + 1
        fld.append(("period_id", 3))
        fld.append(("journal_id", 10))
        fld.append(("journal_type", 50))
        fld.append(("journal_required_fields", 60))
        fld.append(("account_required_fields", 70))
        fld.append(("move_type_id", 80))
        fld.append(("select_to_payment", 90))
        fld.append(("partner_bank_id", 90))
        flds.append("period_id")
        flds.append("journal_id")
        flds.append(("journal_type"))
        flds.append(("journal_required_fields"))
        flds.append(("account_required_fields"))
        flds.append(("move_type_id"))
        flds.append(("select_to_payment"))
        flds.append(("partner_bank_id"))
        fields["period_id"] = all_journal
        fields["journal_id"] = all_journal
        fields["journal_type"] = all_journal
        fields["journal_required_fields"] = all_journal
        fields["account_required_fields"] = all_journal
        fields["move_type_id"] = all_journal
        fields["select_to_payment"] = all_journal
        fields["partner_bank_id"] = all_journal
        fld = sorted(fld, key=itemgetter(1))
        widths = {"statement_id": 50, "state": 60, "tax_code_id": 50, "move_id": 40}

        document = etree.Element(
            "tree",
            string=title,
            editable="top",
            refresh="5",
            on_write="on_create_write",
            colors="red:state=='draft';black:state=='valid'",
        )
        fields_get = self.fields_get(cr, uid, flds, context)
        for field, _seq in fld:
            if common_fields.get(field) == total:
                fields.get(field).append(None)
            # if field=='state':
            #     state = 'colors="red:state==\'draft\'"'
            f = etree.SubElement(document, "field", name=field)

            if field == "debit":
                f.set("sum", _("Total debit"))

            elif field == "credit":
                f.set("sum", _("Total credit"))

            elif field == "move_id":
                f.set("required", "False")

            elif field == "account_tax_id":
                f.set("domain", "[('parent_id', '=' ,False)]")
                f.set("context", "{'journal_id': journal_id}")

            elif field == "account_id" and journal.id:
                f.set("domain", "[('journal_id', '=', journal_id),('type','!=','view'), ('type','!=','closed')]")
                f.set("on_change", "onchange_account_id(account_id, partner_id)")

            elif field == "partner_id":
                f.set(
                    "on_change", "onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"
                )

            elif field == "journal_id":
                f.set("context", "{'journal_id': journal_id}")
                f.set("on_change", "onchange_journal_id(journal_id)")

            elif field == "statement_id":
                f.set("domain", "[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]")
                f.set("invisible", "True")

            elif field == "date":
                f.set("on_change", "onchange_date(date)")

            elif field == "analytic_account_id":
                # Currently it is not working due to being executed by superclass's fields_view_get
                # f.set('groups', 'analytic.group_analytic_accounting')
                pass

            # elif field in ('journal_type', 'journal_required_fields', 'account_required_fields', 'select_to_payment', 'move_type_id', 'partner_bank_id'):
            #    f.set('invisible', 'True')

            elif field == "select_to_payment":
                f.set("on_change", "onchange_select_to_payment(partner_id)")

            if field in ("amount_currency", "currency_id"):
                f.set("on_change", "onchange_currency(account_id, amount_currency, currency_id, date, journal_id)")
                f.set("attrs", "{'readonly': [('state', '=', 'valid')]}")

            if field in widths:
                f.set("width", str(widths[field]))

            if field in ("journal_id",):
                f.set("invisible", "context.get('journal_id', False)")
            elif field in ("period_id",):
                f.set("invisible", "context.get('period_id', False)")

            orm.setup_modifiers(f, fields_get[field], context=context, in_tree_view=True)

        result["arch"] = etree.tostring(document, pretty_print=True)
        result["fields"] = fields_get
        return result
Ejemplo n.º 13
0
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        res = super(product_product,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
        if context is None:
            context = {}
        if ('location' in context) and context['location']:
            location_info = self.pool.get('stock.location').browse(cr, uid, context['location'])
            fields=res.get('fields',{})
            if fields:
                if location_info.usage == 'supplier':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Receptions')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Received Qty')

                if location_info.usage == 'internal':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Stock')

                if location_info.usage == 'customer':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Deliveries')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Delivered Qty')

                if location_info.usage == 'inventory':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future P&L')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('P&L Qty')

                if location_info.usage == 'procurement':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Qty')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Unplanned Qty')

                if location_info.usage == 'production':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Productions')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Produced Qty')
        return res
Ejemplo n.º 14
0
    def fields_view_get(self, cr, uid, view_id=None, view_type="form", context=None, toolbar=False, submenu=False):
        res = super(product_product, self).fields_view_get(
            cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu
        )
        if context is None:
            context = {}
        if ("location" in context) and context["location"]:
            location_info = self.pool.get("stock.location").browse(cr, uid, context["location"])
            fields = res.get("fields", {})
            if fields:
                if location_info.usage == "supplier":
                    if fields.get("virtual_available"):
                        res["fields"]["virtual_available"]["string"] = _("Future Receptions")
                    if fields.get("qty_available"):
                        res["fields"]["qty_available"]["string"] = _("Received Qty")

                if location_info.usage == "internal":
                    if fields.get("virtual_available"):
                        res["fields"]["virtual_available"]["string"] = _("Future Stock")

                if location_info.usage == "customer":
                    if fields.get("virtual_available"):
                        res["fields"]["virtual_available"]["string"] = _("Future Deliveries")
                    if fields.get("qty_available"):
                        res["fields"]["qty_available"]["string"] = _("Delivered Qty")

                if location_info.usage == "inventory":
                    if fields.get("virtual_available"):
                        res["fields"]["virtual_available"]["string"] = _("Future P&L")
                    if fields.get("qty_available"):
                        res["fields"]["qty_available"]["string"] = _("P&L Qty")

                if location_info.usage == "procurement":
                    if fields.get("virtual_available"):
                        res["fields"]["virtual_available"]["string"] = _("Future Qty")
                    if fields.get("qty_available"):
                        res["fields"]["qty_available"]["string"] = _("Unplanned Qty")

                if location_info.usage == "production":
                    if fields.get("virtual_available"):
                        res["fields"]["virtual_available"]["string"] = _("Future Productions")
                    if fields.get("qty_available"):
                        res["fields"]["qty_available"]["string"] = _("Produced Qty")
        return res
Ejemplo n.º 15
0
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        res = super(product_product,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
        if context is None:
            context = {}
        if ('location' in context) and context['location'] and type(context['location']) == type(1):
            location_info = self.pool.get('stock.location').read(cr, uid,
                    context['location'], ['usage'])
            fields=res.get('fields',{})
            if fields:
                if location_info['usage'] == 'supplier':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Receptions')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Received Qty')

                elif location_info['usage'] == 'internal':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Stock')

                elif location_info['usage'] == 'customer':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Deliveries')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Delivered Qty')

                elif location_info['usage'] == 'inventory':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future P&L')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('P&L Qty')

                elif location_info['usage'] == 'procurement':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Qty')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Unplanned Qty')

                elif location_info['usage'] == 'production':
                    if fields.get('virtual_available'):
                        res['fields']['virtual_available']['string'] = _('Future Productions')
                    if fields.get('qty_available'):
                        res['fields']['qty_available']['string'] = _('Produced Qty')
        return res
Ejemplo n.º 16
0
    def fields_view_get(self,
                        cr,
                        uid,
                        view_id=None,
                        view_type='form',
                        context=None,
                        toolbar=False,
                        submenu=False):
        res = super(product_product, self).fields_view_get(cr,
                                                           uid,
                                                           view_id=view_id,
                                                           view_type=view_type,
                                                           context=context,
                                                           toolbar=toolbar,
                                                           submenu=submenu)
        if not context:
            context = {}
        model_bg = context.get('model_bg', False)
        model_bg_ids = context.get('model_bg_ids', [])
        is_supply_list = False
        is_bom_move = False
        if model_bg == 'stock.picking.out' and model_bg_ids:
            for picking in self.pool.get('stock.picking.out').browse(
                    cr, uid, model_bg_ids):
                if picking.is_supply_list:
                    is_supply_list = True
                elif picking.is_bom_move:
                    is_bom_move = True

        # Location is mo, bom move and supply list
        if model_bg == 'mrp.production' or is_supply_list or is_bom_move:
            doc = etree.XML(res['arch'])
            nodes = doc.xpath("//tree/field[@name='sqp_virtual_available']") + \
                doc.xpath("//tree/field[@name='qty_available']") + \
                doc.xpath("//tree/field[@name='sqp_incoming_qty']") + \
                doc.xpath("//tree/field[@name='sqp_outgoing_qty']") + \
                doc.xpath("//tree/field[@name='sqp_qty_mo_resv']") + \
                doc.xpath("//tree/field[@name='qty_safety']") + \
                doc.xpath("//tree/field[@name='sqp_qty_reorder']")

            for node in nodes:
                node.set('invisible', 'false')
                node.set('modifiers',
                         '{"readonly": true, "tree_invisible": false}')
            res['arch'] = etree.tostring(doc)

        # change string sqp_virtual_available follow location info
        if ('location' in context) and context['location']:
            location_info = self.pool.get('stock.location').browse(
                cr, uid, context['location'])
            fields = res.get('fields', {})
            if fields:
                if location_info.usage == 'supplier':
                    if fields.get('sqp_virtual_available'):
                        res['fields']['sqp_virtual_available']['string'] = _(
                            'SPS Future Receptions')

                if location_info.usage == 'internal':
                    if fields.get('sqp_virtual_available'):
                        res['fields']['sqp_virtual_available']['string'] = _(
                            'SPS Future Stock')

                if location_info.usage == 'customer':
                    if fields.get('sqp_virtual_available'):
                        res['fields']['sqp_virtual_available']['string'] = _(
                            'SPS Future Deliveries')

                if location_info.usage == 'inventory':
                    if fields.get('sqp_virtual_available'):
                        res['fields']['sqp_virtual_available']['string'] = _(
                            'SPS Future P&L')

                if location_info.usage == 'procurement':
                    if fields.get('sqp_virtual_available'):
                        res['fields']['sqp_virtual_available']['string'] = _(
                            'SPS Future Qty')

                if location_info.usage == 'production':
                    if fields.get('sqp_virtual_available'):
                        res['fields']['sqp_virtual_available']['string'] = _(
                            'SPS Future Productions')
        return res