• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python access.get_active_company函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中netforce.access.get_active_company函数的典型用法代码示例。如果您正苦于以下问题:Python get_active_company函数的具体用法?Python get_active_company怎么用?Python get_active_company使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_active_company函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_report_data_custom

    def get_report_data_custom(self, ids, context={}):
        company_id = get_active_company()
        comp = get_model("company").browse(company_id)
        if ids:
            params = self.read(ids, load_m2o=False)[0]
        else:
            params = self.default_get(load_m2o=False, context=context)
        settings = get_model("settings").browse(1)
        date_from = params.get("date_from")
        date_to = params.get("date_to")
        d0 = datetime.strptime(date_from, "%Y-%m-%d")
        year_date_from = d0.strftime("%Y-01-01")  # XXX: get company fiscal year
        prev_date_from = (d0 - timedelta(days=1) - relativedelta(day=1)).strftime("%Y-%m-%d")
        prev_date_to = (d0 - timedelta(days=1) + relativedelta(day=31)).strftime("%Y-%m-%d")

        year_date_from_prev_year = (
            datetime.strptime(year_date_from, "%Y-%m-%d") - relativedelta(years=1)).strftime("%Y-%m-%d")
        date_from_prev_year = (datetime.strptime(date_from, "%Y-%m-%d") - relativedelta(years=1)).strftime("%Y-%m-%d")
        date_to_prev_year = (datetime.strptime(date_to, "%Y-%m-%d") - relativedelta(years=1)).strftime("%Y-%m-%d")

        data = {
            "date_from": date_from,
            "date_to": date_to,
            "year_date_from": year_date_from,
            "prev_date_from": prev_date_from,
            "prev_date_to": prev_date_to,
            "company_name": comp.name,
            "year_date_from_prev_year": year_date_from_prev_year,
            "date_from_prev_year": date_from_prev_year,
            "date_to_prev_year": date_to_prev_year,
        }
        print("data", data)
        return data
开发者ID:jzoldyck,项目名称:netforce,代码行数:33,代码来源:report_profit_loss.py


示例2: get_report_data

 def get_report_data(self, ids, context={}):
     company_id = get_active_company()
     company_ids = get_model("company").search([["id", "child_of", company_id]])
     comp = get_model("company").browse(company_id)
     if ids:
         params = self.read(ids, load_m2o=False)[0]
     else:
         params = self.default_get(load_m2o=False, context=context)
     settings = get_model("settings").browse(1)
     date_from = params.get("date_from")
     if not date_from:
         date_from = date.today().strftime("%Y-%m-01")
     date_to = params.get("date_to")
     if not date_to:
         date_to = (date.today() + relativedelta(day=31)).strftime("%Y-%m-%d")
     data = {
         "company_name": comp.name,
         "date_from": date_from,
         "date_to": date_to,
         "by_rate": params.get("by_rate"),
         "by_comp": params.get("by_comp"),
     }
     db = database.get_connection()
     if params.get("by_comp"):
         res = db.query("SELECT c.id AS comp_id,c.name AS comp_name,c.rate AS comp_rate,r.name AS rate_name,SUM(l.credit-l.debit) AS tax_total,SUM(l.tax_base*sign(l.credit-l.debit)) AS base_total FROM account_move_line l,account_move m,account_tax_component c,account_tax_rate r WHERE m.id=l.move_id AND m.state='posted' AND m.date>=%s AND m.date<=%s AND c.id=l.tax_comp_id AND r.id=c.tax_rate_id AND m.company_id IN %s GROUP BY comp_id,comp_name,comp_rate,rate_name ORDER BY comp_name,rate_name",
                        date_from, date_to, tuple(company_ids))
         data["comp_taxes"] = [dict(r) for r in res]
     if params.get("by_rate"):
         res = db.query("SELECT c.id AS comp_id,c.name AS comp_name,c.rate AS comp_rate,r.name AS rate_name,SUM(l.credit-l.debit) AS tax_total,SUM(l.tax_base*sign(l.credit-l.debit)) AS base_total FROM account_move_line l,account_move m,account_tax_component c,account_tax_rate r WHERE m.id=l.move_id AND m.state='posted' AND m.date>=%s AND m.date<=%s AND c.id=l.tax_comp_id AND r.id=c.tax_rate_id AND m.company_id IN %s GROUP BY comp_id,comp_name,comp_rate,rate_name ORDER BY rate_name,comp_name",
                        date_from, date_to, tuple(company_ids))
         data["rate_taxes"] = [dict(r) for r in res]
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:32,代码来源:report_tax_sum.py


示例3: get_report_data

 def get_report_data(self, ids, context={}):
     if ids:
         params = self.read(ids, load_m2o=False)[0]
     else:
         params = self.default_get(load_m2o=False, context=context)
     company_id = get_active_company()
     comp = get_model("company").browse(company_id)
     settings = get_model("settings").browse(1)
     date_from = params.get("date_from")
     date_to = params.get("date_to")
     if not date_from:
         date_from = date.today().strftime("%Y-%m-01")
     if not date_to:
         date_to = (date.today() + relativedelta(day=31)).strftime("%Y-%m-%d")
     data = {
         "company_name": comp.name,
         "date_from": date_from,
         "date_to": date_to,
         "total_qty": 0,
         "total_amount": 0,
     }
     db = get_connection()
     res = db.query(
         "SELECT l.product_id,p.name AS product_name,p.sale_price AS product_price,SUM(l.amount) AS amount,SUM(l.qty) AS qty FROM account_invoice_line l,account_invoice i,product p WHERE i.id=l.invoice_id AND p.id=l.product_id AND i.date>=%s AND i.date<=%s GROUP BY l.product_id,p.name,p.sale_price ORDER BY p.name", date_from, date_to)
     lines = []
     for r in res:
         line = r
         line["avg_price"] = line["amount"] / line["qty"] if line["qty"] else None
         lines.append(line)
         data["total_qty"] += line["qty"]
         data["total_amount"] += line["amount"]
     data["lines"] = lines
     data["total_avg_price"] = data["total_amount"] / data["total_qty"] if data["total_qty"] else None
     pprint(data)
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:35,代码来源:report_sale_product.py


示例4: get_rate

 def get_rate(self, ids, date=None, rate_type="buy", context={}):
     obj_id = ids[0]
     dbname = database.get_active_db()
     company_id = access.get_active_company()
     key = (dbname, company_id, obj_id, date, rate_type)
     if key in _cache and not context.get("no_cache"):
         return _cache[key]
     obj = self.browse(obj_id)
     res = None
     for rate in obj.rates:
         if rate.company_id.id != company_id:
             continue
         if date and rate.date > date:
             continue
         if rate_type == "buy":
             res = rate.buy_rate
             break
         else:
             res = rate.sell_rate
             break
     if res is None:
         for rate in obj.rates:
             if date and rate.date > date:
                 continue
             if rate_type == "buy":
                 res = rate.buy_rate
                 break
             else:
                 res = rate.sell_rate
                 break
     _cache[key] = res
     return res
开发者ID:analycer,项目名称:netforce,代码行数:32,代码来源:currency.py


示例5: money_out

 def money_out(self, context={}):
     company_id = get_active_company()
     company_ids = get_model("company").search([["id", "child_of", company_id]])
     db = get_connection()
     res = db.query(
         "SELECT COALESCE(l.due_date,l.move_date) AS due_date,SUM(l.credit-l.debit) as amount FROM account_move_line l JOIN account_account a ON a.id=l.account_id LEFT JOIN account_reconcile r ON r.id=l.reconcile_id WHERE l.move_state='posted' AND a.type='payable' AND l.reconcile_id IS NULL AND a.company_id IN %s GROUP BY COALESCE(l.due_date,l.move_date)",
         tuple(company_ids),
     )
     amounts = {}
     for r in res:
         amounts[r.due_date] = r.amount
     values = []
     d0 = date.today()
     d1 = d0 + timedelta(days=60)
     d = d0
     while d < d1:
         ds = d.strftime("%Y-%m-%d")
         values.append((js_time(d), amounts.get(ds, 0)))
         d += timedelta(days=1)
     data = {"value": [{"key": "Payable", "values": values}]}
     res = db.get(
         "SELECT count(*) AS count,SUM(amount_total_cur) AS amount FROM account_invoice WHERE type='in' AND inv_type='invoice' AND state='draft' AND company_id IN %s",
         tuple(company_ids),
     )
     if res:
         data["draft_count"] = res.count
         data["draft_amount"] = res.amount
     res = db.get(
         "SELECT count(*) AS count,SUM(amount_total_cur) AS amount FROM account_invoice WHERE type='in' AND inv_type='invoice' AND state='waiting_payment' AND due_date<now() AND company_id IN %s",
         tuple(company_ids),
     )
     if res:
         data["overdue_count"] = res.count
         data["overdue_amount"] = res.amount
     return data
开发者ID:jzoldyck,项目名称:netforce,代码行数:35,代码来源:report_payable.py


示例6: get_addresses

 def get_addresses(self,ids,context={}):
     vals={}
     comp_id=access.get_active_company()
     for obj in self.browse(ids):
         res=get_model("address").search([["settings_id","=",obj.id],["or",["company_id","=",None],["company_id","child_of",comp_id]]])
         vals[obj.id]=res
     return vals
开发者ID:Sorawit123,项目名称:netforce,代码行数:7,代码来源:settings.py


示例7: get_report_data

 def get_report_data(self, ids, context={}):
     company_id = get_active_company()
     comp = get_model("company").browse(company_id)
     if ids:
         params = self.read(ids, load_m2o=False)[0]
     else:
         params = self.default_get(load_m2o=False, context=context)
     settings = get_model("settings").browse(1)
     if not params.get("account_id"):
         return
     account_id = int(params.get("account_id"))
     date_from = params.get("date_from")
     date_to = params.get("date_to")
     if not date_from and not date_to:
         date_from = date.today().strftime("%Y-%m-01")
         date_to = (date.today() + relativedelta(day=31)).strftime("%Y-%m-%d")
     acc = get_model("account.account").browse(account_id, context={"date_to": date_to})
     acc_balance = acc.balance
     acc_unrec = get_model("account.account").browse(
         account_id, context={"date_to": date_to, "bank_rec_state": "not_reconciled"})
     unrec_paid_amt = acc_unrec.credit
     unrec_received_amt = acc_unrec.debit
     rec_paid = []
     condition = [["account_id", "=", account_id], ["move_id.state", "=", "posted"], ["move_id.date", ">=", date_from], [
         "move_id.date", "<=", date_to], ["state", "=", "reconciled"], ["credit", ">", 0]]
     for line in get_model("account.move.line").search_browse(condition, order="move_id.date,id"):
         vals = {
             "date": line.move_id.date,
             "description": line.description,
             "ref": line.move_id.number,
             "amount": line.credit - line.debit,
         }
         rec_paid.append(vals)
     rec_received = []
     condition = [["account_id", "=", account_id], ["move_id.state", "=", "posted"], ["move_id.date", ">=", date_from], [
         "move_id.date", "<=", date_to], ["state", "=", "reconciled"], ["debit", ">", 0]]
     for line in get_model("account.move.line").search_browse(condition, order="move_id.date,id"):
         vals = {
             "date": line.move_id.date,
             "description": line.description,
             "ref": line.move_id.number,
             "amount": line.debit - line.credit,
         }
         rec_received.append(vals)
     db = database.get_connection()
     data = {
         "company_name": comp.name,
         "date_from": date_from,
         "date_to": date_to,
         "account_name": acc.name,
         "rec_paid": rec_paid,
         "total_rec_paid": sum([l["amount"] for l in rec_paid]),
         "rec_received": rec_received,
         "total_rec_received": sum([l["amount"] for l in rec_received]),
         "acc_balance": acc_balance,
         "unrec_paid_amt": unrec_paid_amt,
         "unrec_received_amt": unrec_received_amt,
         "st_balance": acc_balance + unrec_paid_amt - unrec_received_amt,
     }
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:60,代码来源:report_reconcile.py


示例8: debtor_exposure

 def debtor_exposure(self, context={}):
     company_id = get_active_company()
     company_ids = get_model("company").search([["id", "child_of", company_id]])
     db = get_connection()
     res = db.query(
         "SELECT p.id AS contact_id,p.name AS contact_name,SUM(amount_due_cur) AS amount_due FROM account_invoice i JOIN contact p ON p.id=i.contact_id WHERE i.type='out' AND i.inv_type='invoice' AND i.state='waiting_payment' AND i.company_id IN %s GROUP BY p.id,p.name ORDER BY amount_due DESC LIMIT 10", tuple(company_ids))
     data = [(r.contact_name, r.amount_due) for r in res]
     return {"value": data}
开发者ID:Sorawit123,项目名称:netforce,代码行数:8,代码来源:report_receivable.py


示例9: top_debtors

 def top_debtors(self, context={}):
     company_id = get_active_company()
     company_ids = get_model("company").search([["id", "child_of", company_id]])
     db = get_connection()
     res = db.query(
         "SELECT p.id AS contact_id,p.name AS contact_name,SUM(amount_due_cur) AS amount_due,SUM(CASE WHEN i.due_date<now()::date THEN amount_due_cur ELSE 0 END) AS amount_overdue FROM account_invoice i JOIN contact p ON p.id=i.contact_id WHERE i.type='out' AND i.inv_type='invoice' AND i.state='waiting_payment' AND i.company_id IN %s GROUP BY p.id,p.name ORDER BY amount_due DESC LIMIT 10", tuple(company_ids))
     data = [dict(r) for r in res]
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:8,代码来源:report_receivable.py


示例10: post

 def post(self, ids, context={}):
     obj = self.browse(ids)[0]
     if obj.total_credit != obj.total_credit:
         raise Exception("Debit & Credit is not balance!")
     payrun = obj.payrun_id
     company_id = get_active_company()
     move = payrun.move_id
     if move:
         move.to_draft()
         for line in move.lines:
             line.delete()
     pst = get_model("hr.payroll.settings").browse(1)
     journal = pst.journal_id
     if not journal:
         raise Exception("Please define journal in payroll setting.")
     if not move:
         move_vals = {
             "journal_id": journal.id,
             "number": payrun.number,
             "date": payrun.date_pay,
             "narration": 'Paid-%s' % (payrun.date_pay),
             "related_id": "hr.payrun,%s" % payrun.id,
             "company_id": company_id,
         }
         move_id = get_model("account.move").create(move_vals)
         move = get_model("account.move").browse(move_id)
     lines = []
     for line in obj.lines:
         lines.append(('create', {
             'description': line.description or "",
             'debit': line.debit or 0,
             'credit': line.credit or 0,
             'account_id': line.account_id.id,
         }))
     move.write({
         'lines': lines,
     })
     # XXX
     for payslip in payrun.payslips:
         payslip.write({
             'move_id': move.id,
             'state': 'posted',
         })
     payrun.write({
         'move_id': move.id,
         'state': 'posted',
     })
     return {
         'next': {
             'name': 'payrun',
             'mode': 'form',
             'active_id': payrun.id,
         },
         'flash': 'payrun %s has been posted!' % payrun.number,
     }
开发者ID:Sorawit123,项目名称:netforce,代码行数:55,代码来源:payrun_journal.py


示例11: gen_payslips

    def gen_payslips(self, ids, context={}):
        print("gen_payslips", ids)
        obj = self.browse(ids)[0]
        date = obj.date_from
        emp_ids = get_model("hr.employee").search([["work_status", "=", "working"]])
        for emp in get_model("hr.employee").browse(emp_ids):
            period = 12
            res = get_model("hr.payslip").search([["run_id", "=", obj.id], ["employee_id", "=", emp.id]])
            # TODO: check if payslip exists already
            if res:
                continue
            vals = {
                "employee_id": emp.id,
                "date": date,
                "run_id": obj.id,
                'company_id': get_active_company(),
            }
            lines = []
            ctx = {
                "employee_id": emp.id,
                "date": date,
                "date_from": obj.date_from,
                "date_to": obj.date_to,
            }
            for item in get_model("hr.payitem").search_browse([]):  # XXX
                if item.tax_type == "thai":
                    ctx["year_income"] = (emp.salary or 0.0) * period

                qty, rate = item.compute(context=ctx)

                if not item.show_default:
                    continue

                line_vals = {
                    "payitem_id": item.id,
                    "qty": qty,
                    "rate": rate,
                }
                lines.append(line_vals)

            if emp.profile_id:
                lines = []
                for item in emp.profile_id.pay_items:
                    if item.tax_type == "thai":
                        ctx["year_income"] = (emp.salary or 0.0) * period
                    qty, rate = item.compute(context=ctx)
                    line_vals = {
                        "payitem_id": item.id,
                        "qty": qty,
                        "rate": rate,
                    }
                    lines.append(line_vals)

            vals["lines"] = [("create", line_vals) for line_vals in lines]
            get_model("hr.payslip").create(vals)
开发者ID:Sorawit123,项目名称:netforce,代码行数:55,代码来源:hr_payrun.py


示例12: get_company_currency

 def get_company_currency(self, ids, context={}):
     comp_cur = {}
     comp_id = get_active_company()
     for comp in get_model("company").search_browse([]):
         set_active_company(comp.id)
         comp_settings = get_model("settings").browse(1)
         comp_cur[comp.id] = comp_settings.currency_id.id
     set_active_company(comp_id)
     vals = {}
     for obj in self.browse(ids):
         vals[obj.id] = comp_cur.get(obj.company_id.id)
     return vals
开发者ID:jzoldyck,项目名称:netforce,代码行数:12,代码来源:account_account.py


示例13: get_report_data

 def get_report_data(self, ids, context={}):
     company_id = get_active_company()
     company_ids = get_model("company").search([["id", "child_of", company_id]])
     comp = get_model("company").browse(company_id)
     if ids:
         params = self.read(ids, load_m2o=False)[0]
     else:
         params = self.default_get(load_m2o=False, context=context)
     settings = get_model("settings").browse(1)
     company_name = comp.name
     contact_id = params.get("contact_id")
     if contact_id:
         contact_id = int(contact_id)
     date_from = params.get("date_from")
     date_to = params.get("date_to")
     show_details = params.get("show_details")
     db = get_connection()
     q = "SELECT l.id,m.date AS move_date,l.contact_id,p.name AS contact_name,m.number AS move_number,l.description,COALESCE(l.due_date,m.date) AS due_date,l.credit-l.debit AS total_amount,r.number AS reconcile_number,l.reconcile_id FROM account_move_line l JOIN account_account a ON a.id=l.account_id JOIN account_move m ON m.id=l.move_id LEFT JOIN contact p ON p.id=l.contact_id LEFT JOIN account_reconcile r ON r.id=l.reconcile_id WHERE l.move_state='posted' AND a.type='payable' AND a.company_id IN %s"
     args = [tuple(company_ids)]
     if date_from:
         q += " AND COALESCE(l.due_date,l.move_date)>=%s"
         args.append(date_from)
     if date_to:
         q += " AND COALESCE(l.due_date,l.move_date)<=%s"
         args.append(date_to)
     if contact_id:
         q += " AND l.contact_id=%s"
         args.append(contact_id)
     else:
         q += " AND l.contact_id IS NULL"  # XXX
     if not show_details:
         q += " AND (l.reconcile_id IS NULL OR r.balance!=0)"
     q += " ORDER BY COALESCE(l.due_date,m.date),l.id"
     res = db.query(q, *args)
     lines = []
     for r in res:
         vals = dict(r)
         if vals["reconcile_number"] and not vals["reconcile_number"].endswith("*"):
             vals["due_amount"] = 0
         else:
             vals["due_amount"] = vals["total_amount"]
         lines.append(vals)
     data = {
         "company_name": company_name,
         "date_from": date_from,
         "date_to": date_to,
         "lines": lines,
         "totals": {
             "amount_total": sum(l["due_amount"] for l in lines),
         }
     }
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:52,代码来源:report_supp_invoice.py


示例14: get_report_data

 def get_report_data(self, ids, context={}):
     if ids:
         params = self.read(ids, load_m2o=False)[0]
     else:
         params = self.default_get(load_m2o=False, context=context)
     company_id = get_active_company()
     comp = get_model("company").browse(company_id)
     settings = get_model("settings").browse(1)
     date_from = params["date_from"]
     date_to = params["date_to"]
     contact_id = params.get("contact_id")
     account_id = params.get("account_id")
     data = {
         "company_name": comp.name,
         "date_from": date_from,
         "date_to": date_to,
     }
     cond = [["account_id.type", "in", ["cost_sales", "expense", "other_expense"]],
            ["move_id.date", ">=", date_from], ["move_id.date", "<=", date_to]]
     if contact_id:
         cond.append(["contact_id", "=", contact_id])
     if account_id:
         cond.append(["account_id", "=", account_id])
     groups = {}
     for obj in get_model("account.move.line").search_browse(cond, order="move_id.date"):
         line_vals = {
             "id": obj.id,
             "date": obj.move_id.date,
             "number": obj.move_id.number,
             "description": obj.description,
             "account_id": obj.account_id.id,
             "account_code": obj.account_id.code,
             "account_name": obj.account_id.name,
             "amount": obj.debit - obj.credit,
         }
         contact_id = obj.contact_id.id
         if contact_id in groups:
             group = groups[contact_id]
         else:
             group = {
                 "contact_id": contact_id,
                 "contact_name": obj.contact_id.name,
                 "lines": [],
             }
             groups[contact_id] = group
         group["lines"].append(line_vals)
     data["groups"] = sorted(groups.values(), key=lambda g: g["contact_name"] or "")
     for group in data["groups"]:
         group["total"] = sum([l["amount"] for l in group["lines"]])
     pprint(data)
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:51,代码来源:report_account_purchase.py


示例15: payable_status

 def payable_status(self, context={}):
     company_id = get_active_company()
     company_ids = get_model("company").search([["id", "child_of", company_id]])
     data = {}
     for st in ("draft", "waiting_approval", "waiting_payment"):
         data[st] = {"count": 0, "amount": 0}
     db = get_connection()
     res = db.query(
         "SELECT state,COUNT(*) as count,SUM(amount_due_cur) as amount FROM account_invoice WHERE type='in' AND inv_type='invoice' AND company_id IN %s GROUP BY state",
         tuple(company_ids),
     )
     for r in res:
         data[r["state"]] = {"count": r["count"], "amount": r["amount"]}
     return data
开发者ID:jzoldyck,项目名称:netforce,代码行数:14,代码来源:report_payable.py


示例16: gen_tax_no

 def gen_tax_no(self, exclude=None, context={}):
     company_id = get_active_company()  # XXX: improve this?
     seq_id = get_model("sequence").find_sequence(type="tax_no")
     if not seq_id:
         return None
     while 1:
         num = get_model("sequence").get_next_number(seq_id, context=context)
         if exclude and num in exclude:
             get_model("sequence").increment_number(seq_id, context=context)
             continue
         res = get_model("account.move.line").search([["tax_no", "=", num], ["move_id.company_id", "=", company_id]])
         if not res:
             return num
         get_model("sequence").increment_number(seq_id, context=context)
开发者ID:Sorawit123,项目名称:netforce,代码行数:14,代码来源:account_invoice.py


示例17: get_report_data

 def get_report_data(self, ids, context={}):
     company_id = get_active_company()
     comp = get_model("company").browse(company_id)
     if ids:
         params = self.read(ids, load_m2o=False)[0]
     else:
         params = self.default_get(load_m2o=False, context=context)
     settings = get_model("settings").browse(1)
     db = database.get_connection()
     if not params.get("account_id"):
         return
     account_id = int(params.get("account_id"))
     date = params.get("date")
     if not date:
         date = time.strftime("%Y-%m-%d")
     ctx = {
         "date_to": date,
     }
     acc = get_model("account.account").browse([account_id], context=ctx)[0]
     payments = []
     for obj in get_model("account.move.line").search_browse([["account_id", "=", account_id], ["state", "!=", "reconciled"], ["move_id.state", "=", "posted"], ["move_id.date", "<=", date]], order="move_id.date"):
         vals = {
             "date": obj.move_id.date,
             "description": obj.description,
             "ref": obj.move_id.number,
             "amount": obj.credit - obj.debit,
         }
         payments.append(vals)
     st_lines = []
     for obj in get_model("account.statement.line").search_browse([["statement_id.account_id", "=", account_id], ["state", "!=", "reconciled"], ["date", "<=", date]], order="date"):
         vals = {
             "date": obj.date,
             "description": obj.description,
             "ref": "",  # XXX
             "amount": obj.received - obj.spent,
         }
         st_lines.append(vals)
     data = {
         "company_name": comp.name,
         "date": date,
         "account_name": acc.name,
         "account_balance": acc.balance,
         "move_lines": payments,
         "total_move_lines": sum([p["amount"] for p in payments]),
         "statement_lines": st_lines,
         "total_statement_lines": sum([l["amount"] for l in st_lines]),
     }
     data["statement_balance"] = data["account_balance"] + data["total_move_lines"] + data["total_statement_lines"]
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:49,代码来源:report_bank_rec.py


示例18: get_report_data

 def get_report_data(self, ids, context={}):
     company_id = get_active_company()
     comp = get_model("company").browse(company_id)
     if ids:
         params = self.read(ids, load_m2o=False)[0]
     else:
         params = self.default_get(load_m2o=False, context=context)
     settings = get_model("settings").browse(1)
     date_from = params.get("date_from")
     date_to = params.get("date_to")
     cond = [["date", ">=", date_from], ["date", "<=", date_to], ["purchase_type_id.commission_po", "=", True]]
     groups = {}
     for purch in get_model("purchase.order").search_browse(cond, order="date"):
         group = groups.get(purch.customer_id.id)
         if group is None:
             group = {
                 "customer": purch.customer_id.name or "N/A",
                 "lines": [],
             }
             groups[purch.customer_id.id] = group
         line = {
             "id": purch.id,
             "date": purch.date,
             "number": purch.number,
             "supplier": purch.contact_id.name,
             "number": purch.number,
             "amount_subtotal": purch.amount_subtotal,
             "commission_percent": purch.customer_id.commission_po_percent,  # XXX
             "commission_amount": purch.amount_subtotal * (purch.customer_id.commission_po_percent or 0) / 100,
         }
         group["lines"].append(line)
     groups = sorted(groups.values(), key=lambda g: g["customer"])
     for group in groups:
         totals = {}
         totals["amount_subtotal"] = sum(l["amount_subtotal"] or 0 for l in group["lines"])
         totals["commission_amount"] = sum(l["commission_amount"] or 0 for l in group["lines"])
         group["totals"] = totals
     totals = {}
     totals["amount_subtotal"] = sum(g["totals"]["amount_subtotal"] for g in groups)
     totals["commission_amount"] = sum(g["totals"]["commission_amount"] for g in groups)
     data = {
         "company_name": comp.name,
         "date_from": date_from,
         "date_to": date_to,
         "groups": groups,
         "totals": totals,
     }
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:48,代码来源:report_commission_po.py


示例19: get_report_data

 def get_report_data(self, ids, context={}):
     company_id = get_active_company()
     comp = get_model("company").browse(company_id)
     if ids:
         params = self.read(ids, load_m2o=False)[0]
     else:
         params = self.default_get(load_m2o=False, context=context)
     settings = get_model("settings").browse(1)
     date_from = params.get("date_from")
     date_to = params.get("date_to")
     pay_method_id = params.get("pay_method_id")
     lines = []
     cond = [["state", "=", "confirmed"]]
     if date_from:
         cond.append(["date", ">=", date_from])
     if date_to:
         cond.append(["date", "<=", date_to])
     if pay_method_id:
         cond.append(["pay_method_id", "=", pay_method_id])
     for sale in get_model("sale.order").search_browse(cond, order="date,id"):
         if sale.is_paid:
             continue
         contact = sale.contact_id
         phone = contact.phone
         for addr in contact.addresses:
             if phone:
                 break
             phone = addr.phone
         line = {
             "id": sale.id,
             "number": sale.number,
             "related_id": sale.related_id.id if sale.related_id else None,
             "related_number": sale.related_id.number if sale.related_id else None,
             "date": sale.date,
             "customer_name": contact.name,
             "phone": phone,
             "pay_method": sale.pay_method_id.name if sale.pay_method_id else None,
             "amount": sale.amount_total,
         }
         lines.append(line)
     data = {
         "company_name": comp.name,
         "date_from": date_from,
         "date_to": date_to,
         "lines": lines,
         "total": sum(l["amount"] for l in lines),
     }
     return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:48,代码来源:report_unpaid_sale.py


示例20: get_data_pick_internal_form

    def get_data_pick_internal_form(self, context={}):
        company_id = get_active_company()
        comp = get_model("company").browse(company_id)
        obj_id = int(context["refer_id"])
        obj = get_model("stock.picking").browse(obj_id)
        settings = get_model("settings").browse(1)
        comp_addr = settings.get_address_str()
        comp_name = comp.name
        comp_phone = settings.phone
        comp_fax = settings.fax
        comp_tax_no = settings.tax_no
        contact = obj.contact_id
        cust_addr = contact.get_address_str()
        cust_name = contact.name
        cust_fax = contact.fax
        cust_phone = contact.phone
        cust_tax_no = contact.tax_no

        data = {
            "comp_name": comp_name,
            "comp_addr": comp_addr,
            "comp_phone": comp_phone or "-",
            "comp_fax": comp_fax or "-",
            "comp_tax_no": comp_tax_no or "-",
            "cust_name": cust_name,
            "cust_addr": cust_addr,
            "cust_phone": cust_phone or "-",
            "cust_fax": cust_fax or "-",
            "cust_tax_no": cust_tax_no or "-",
            "date": obj.date,
            "number": obj.number,
            "ref": obj.ref,
            "lines": [],
        }
        if settings.logo:
            data["logo"] = get_file_path(settings.logo)
        for line in obj.lines:
            data["lines"].append({
                "product": line.product_id.name,
                "description": line.product_id.description,
                "qty": line.qty,
                "uom": line.uom_id.name,
                "location_from": line.location_from_id.name,
                "location_to": line.location_to_id.name,
                "cost_price": line.cost_price,
            })
        return data
开发者ID:Sorawit123,项目名称:netforce,代码行数:47,代码来源:report_stock.py



注:本文中的netforce.access.get_active_company函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python access.get_active_user函数代码示例发布时间:2022-05-27
下一篇:
Python netfilterqueue.NetfilterQueue类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap