コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

Inherit timesheet_grid and adjust_grid

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
timesheetenterprisegridodoo16features
1 返信
2065 ビュー
アバター
Allan PEREZ

Hey

I'm using odoo enterprise, and I'm trying to inherit account.analytic.line and the method adjust_grid to avoid people to timesheet on a project after a date limit represented by the field date_done.

So in my module, I inherit account.analytic.line but my function is never called when I timesheet on a project, it seems that my override is not working. Any idea why ?
Here my code, I just copy paste the function from the class and add some log. I work with odoo.sh. Also my manifest depend of timesheet_grid, and my model is correctly loaded in my __init__ files

"depends": [
"base",
"project",
"timesheet_grid",
...
],

import logging
from odoo import tools, models, fields, api, _
from odoo.osv import expression
from odoo.exceptions import UserError, AccessError

_logger = logging.getLogger(__name__)

class AnalyticLine(models.Model):
_inherit = ['account.analytic.line']
def controlIfProjectIsDone(self):
_logger.debug("-------------------------")
_logger.debug("TEST")
_logger.debug("-------------------------")

def adjust_grid(self, row_domain, column_field, column_value, cell_field, change):
self.controlIfProjectIsDone()
if column_field != 'date' or cell_field != 'unit_amount':
raise ValueError(
"{} can only adjust unit_amount (got {}) by date (got {})".format(
self._name,
cell_field,
column_field,
))

additionnal_domain = self._get_adjust_grid_domain(column_value)
# Remove date from the domain
new_row_domain = []
for leaf in row_domain:
if leaf[0] == 'date':
new_row_domain += ['|', expression.TRUE_LEAF, leaf]
else:
new_row_domain.append(leaf)
domain = expression.AND([new_row_domain, additionnal_domain])
line = self.search(domain)

if line.project_id and not line.project_id.allow_timesheets:
raise UserError(_("You cannot adjust the time of the timesheet for a project with timesheets disabled."))

day = column_value.split('/')[0]


if len(line) > 1 or len(line) == 1 and line.validated: # copy the last line as adjustment
line[0].copy(self._prepare_duplicate_timesheet_line_values(
column_field, day, cell_field, change)
)
elif len(line) == 1: # update existing line
line.write({
cell_field: line[cell_field] + change
})
else: # create new one
line_in_domain = self.search(row_domain, limit=1)
if line_in_domain:
line_in_domain.copy(self._prepare_duplicate_timesheet_line_values(
column_field, day, cell_field, change)
)
else:
project, task = self._get_project_task_from_domain(domain)

if task and not project:
project = self.env['project.task'].browse([task]).project_id.id

if project:
_logger.debug("-------------------------------------------------")
_logger.debug("day %s", day)
_logger.debug("date done %s", project.date_done)
self.create([{
'project_id': project,
'task_id': task,
column_field: day,
cell_field: change,
}])

return False


0
アバター
破棄
アバター
Nomadoo
最善の回答

It seems like you are trying to override the adjust_grid method in the account.analytic.line model to add some additional logic. Your code looks correct for the most part, but there are a few things to check:


    Correct Inheritance:

    Ensure that your module depends on the timesheet_grid module and that it is correctly loaded before your module. The adjust_grid method is part of the timesheet_grid module, so if your module is not loaded after it, your override might not take effect.


    Check Log Output:

    The logging statements you've added (_logger.debug) should appear in the logs if the controlIfProjectIsDone method is being called. Check the logs to see if you find the log statements when timesheeting on a project.


    Method Signature:

    Verify that the method signature matches exactly with the method you are trying to override. If there have been changes in the Odoo version you are using, the method signature might differ, leading to your override not being recognized.


    Ensure Correct Module Dependencies:

    Ensure that your module's dependencies are correctly specified in the manifest file, and there are no conflicts or issues with other modules.


    Restart Odoo Service:

    After making changes to your code, restart the Odoo service to ensure that the changes are picked up.


    Check for Syntax Errors:

    Ensure that there are no syntax errors in your Python code that could prevent the correct loading of your module.

---------------------------------

    Use Decorators:

    In Odoo, decorators are often used for method overrides. Try using the @api.multi decorator on your overridden method to ensure it's recognized as a multi-record method.

@api.multi

def adjust_grid(self, row_domain, column_field, column_value, cell_field, change):

    # Your code here


---------------------------------


If, after checking these points, the issue persists, you may want to look into the Odoo server logs for any error messages or warnings that could provide more insight into why your method override is not working as expected

0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Embed video from YouTube using the website builder Odoo 16 解決済
enterprise odoo16features
アバター
アバター
1
7月 23
3955
[SOLVED] Timesheet grid view
timesheet grid
アバター
0
11月 17
6915
Odoo Default terms and conditions on other page or backside of document
enterprise Odoo.sh odoo16features
アバター
アバター
1
5月 25
2125
extending pos_settle_due PaymentScreen
enterprise odoo16features pointofsale
アバター
アバター
1
8月 24
2512
Record does not exist or has been deleted. (Record: ir.actions.report(1,), User: 1) odoo 16 解決済
enterprise report odoo16features
アバター
アバター
アバター
アバター
3
4月 24
9271
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now