تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (BI)
    • المستندات
    • توقيع إلكتروني
    المبيعات
    • إدارة علاقات العملاء
    • المبيعات
    • نقطة البيع للمتاجر
    • نقطة البيع للمطاعم
    • الاشتراكات
    • تأجير
    المواقع الإلكترونية
    • أداة بناء المواقع الإلكترونية
    • متاجر إلكترونية
    • مدونة
    • المنتدى
    • دردشة مباشرة
    • التعليم الإلكتروني
    سلسلة التوريد
    • المستودعات
    • التصنيع
    • إدارة دورة حياة المنتج
    • المشتريات
    • الصيانة
    • الجودة
    الموارد البشرية
    • موظفون
    • التوظيف
    • إجازة عمل
    • التقييمات
    • الإحالات
    • تطبيق الأسطول
    التسويق
    • التسويق الإجتماعي
    • التسويق عبر البريد الإلكتروني
    • التسويق عبر الرسائل النصية
    • فعاليات
    • أتمتة التسويق
    • الاستطلاعات
    الخدمات
    • المشاريع
    • الجداول الزمنية
    • الخدمة الميدانية
    • مكتب المساعدة
    • التخطيط
    • مواعيد
    اﻹنتاجية
    • مناقشة
    • الموافقات
    • إنترنت الأشياء "IoT"
    • بروتوكول ربط المحادثات الصوتية عبر الإنترنت
    • المعرفة
    • WhatsApp
    التطبيقات الخارجية ستوديو أودو منصة أودو السحابية
  • قطاعات الأعمال
    البيع بالتجزئة
    • متجر كتب
    • متجر ملابس
    • متجر أثاث
    • متجر بقالة
    • متجر معدات
    • متجر ألعاب
    الطعام والضيافة
    • بار وحانة
    • المطعم
    • مطعم للوجبات السريعة
    • نزل للضيوف
    • موزّع مشروبات
    • فندق
    العقارات
    • وكالة عقارات
    • شركة هندسة معمارية
    • البناء
    • إدارة العقارات
    • العناية بالحدائق
    • اتحاد مُلاّك العقارات
    استشارة
    • مؤسسة محاسبية
    • شريك أودو
    • وكالة تسويقية
    • منشأة قانونية
    • استقطاب المواهب
    • التدقيق والتوثيق
    التصنيع
    • الأقمشة
    • معدني
    • الأثاث
    • الطعام
    • مصنع خمور
    • هدايا الشركات
    الصحة واللياقة البدنية
    • نادي رياضي
    • متجر نظارات
    • مركز لياقة بدنية
    • الممارسون الصحيون
    • صيدلية
    • صالون تصفيف الشعر
    التجارة
    • عامل صيانة
    • الأجهزة والمعدات التقنية ودعمها
    • أنظمة الطاقة الشمسية
    • صانع أحذية
    • خدمات التنظيف
    • خدمات التكييف (HVAC)
    غير ذلك
    • منظمة غير ربحية
    • وكالة بيئية
    • تأجير لوحات إعلانية
    • تصوير
    • تأجير دراجات
    • بائع وسيط للبرمجيات
    تصفح كافة قطاعات الأعمال
  • مجتمع أودو
    تعلم
    • دروس
    • التوثيق
    • شهادات
    • التدريب
    • مدونة
    • بودكاست
    قم بتعزيز التعليم
    • برنامج تعليم
    • Scale UP! لعبة الأعمال
    • قم بزيارة أودو
    احصل على البرنامج
    • تحميل
    • قارنْ الإصدارات
    • إطلاق
    تعاون
    • جيت هاب "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:

  • إدارة علاقات العملاء
  • e-Commerce
  • المحاسبة
  • المخزون
  • PoS
  • المشروع
  • MRP
All apps
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
المساعدة

Action to update a value in multiple records

اشتراك

تسلم الإشعارات عندما يكون هناك نشاط في هذا المنشور

لقد تم الإبلاغ عن هذا السؤال
actionv12
2 الردود
21462 أدوات العرض
الصورة الرمزية
Ali Mahmoud

Hi,

i have a field called "phase" inside "account.payment" model.

i want to create an action that change the phase of selected payments, not only one payment,  to a phase i choose

it's my first time to do something like this. so any help or suggestion ,or how to start, would be welcome

Thanks!

1
الصورة الرمزية
إهمال
الصورة الرمزية
Waleed Ali Mohsen
أفضل إجابة

Hi,

You can use wizard with transient model and add “Update Payments Phase” action to Actions menu, so you will select the payments from list view and then from action you will select “Update Payments Phase” action and the wizard form will be shown and you will select the phase from the list and you will have a button in wizard form to update the phase and you will write the code which change the phase to the selected phase.

Transient Model (Wizard)


class AccountPaymentsPhaseWizard(models.TransientModel):
_name = "account.payments.phase.wizard"
_description = "Update the phase for multi payemnt"

# define the phase field which you will use to change the phase for the selected payments, for example if the phase field is a selection
phase = fields.Selection([('phase1', 'phase1'), ('phase2', 'phase2'), ('phase3', 'phase3')],string='phase')

# method update_payments_phase which will be called from wizard once click on Update phase button
@api.multi
def update_payments_phase(self):
# return all selected payments using active_ids and you can filter them and use any validation you want
payments = self.env['account.payments'].browse(self._context.get('active_ids'))
# loop the payments
for payment in payments:
# set the selected phase for each payment
payment.phase = self.phase

Form View and action for transient model:

<record id="view_account_payment_from_change_phase" model="ir.ui.view">
<field name="name">account.phase.payments.wizard</field>
<field name="model">account.payments.phase.wizard</field>
<field name="arch" type="xml">
<form string="Change Phase">
<field name=" phase"/>
<footer>
<button string='Update Phase' name="update_payments_phase" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>

<!-- Action to launch Wizard for change phase of payments from action menu -->
<record id=" view_account_payment_from_change_phase_action" model="ir.actions.act_window">
<field name="name">Update Payments Phase</field>
<field name="res_model">account.payments.phase.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_payment_from_change_phase"/>
<field name="target">new</field>
<field name="binding_model_id" ref="account.model_account_payment"/>
</record>



1
الصورة الرمزية
إهمال
Ali Mahmoud
الكاتب

Thank you, That's what i needed exactly, but i'm getting this error when trying to change the phase:

The operation cannot be completed, probably due to the following:

- deletion: you may be trying to delete a record while other records still reference it

- creation/update: a mandatory field is not correctly set

[object with reference: payment_type - payment.type]

and when i see the log, i see that this action is creating a new payment, not updating an existed one

any suggestion?

Thanks again

Waleed Ali Mohsen

Could you please share you code?

Ali Mahmoud
الكاتب

in models:

class AccountPaymentsPhaseWizard(models.TransientModel):

_name = 'account.payments.phase.wizard'

_inherit = 'account.payment'

@api.multi

def update_payments_phase(self):

payments = self.env['account.payment'].browse(self._context.get('active_ids'))

for payment in payments:

payment.phase = self.phase

in views:

<record id="view_account_payment_from_change_phase" model="ir.ui.view">

<field name="name">account.payments.phase.wizard</field>

<field name="model">account.payments.phase.wizard</field>

<field name="arch" type="xml">

<form string="Change Phase">

<field name="phase"/>

<footer>

<button string='Update Phase' name="update_payments_phase" type="object" class="btn-primary"/>

<button string="Cancel" class="btn-default" special="cancel"/>

</footer>

</form>

</field>

</record>

<!-- Action to launch Wizard for change phase of payments from action menu -->

<record id="view_account_payment_from_change_phase_action" model="ir.actions.act_window">

<field name="name">Update Payments Phase</field>

<field name="res_model">account.payments.phase.wizard</field>

<field name="view_type">form</field>

<field name="view_mode">form</field>

<field name="view_id" ref="view_account_payment_from_change_phase"/>

<field name="target">new</field>

<field name="binding_model_id" ref="account.model_account_payment"/>

</record>

Waleed Ali Mohsen

You should not inherit from account.payment, please see my answer code above.

You have to define a field phase in wizard same as the one in account.payment

class AccountPaymentsPhaseWizard(models.TransientModel):

_name = 'account.payments.phase.wizard'

phase = fields.Selection([('phase1', 'phase1'), ('phase2', 'phase2'), ('phase3', 'phase3')],string='phase')

@api.multi

def update_payments_phase(self):

payments = self.env['account.payment'].browse(self._context.get('active_ids'))

for payment in payments:

payment.phase = self.phase

Ali Mahmoud
الكاتب

yes, it was my mistake.

It works now! Thanks

Waleed Ali Mohsen

Nice to hear that.

Boby

Hi Waleed Mohsen,

I have question about filtering that browse, you said # return all selected payments using active_ids and you can filter them and use any validation you want.

I have problem to find the active_ids and the state must only in 'open'

Any advice?

الصورة الرمزية
Kanakinfosystems
أفضل إجابة

Hello, 

You can do with the Server Action. 

For Static Value
​

A)Where you have to select the "Updated the Record" and model is "account.payment" 
and on the Data to write just added that field and it's value and save that record and create the action and run on selected records.
 

For Dynamic Value

B) You can do with "Execute Python code" and run that with function.
will update the value dynamically(based on you code).


Thanks,
​
1
الصورة الرمزية
إهمال
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Get current menuitem ID and action ID of a form. تم الحل
action menuitem v12
الصورة الرمزية
الصورة الرمزية
2
ديسمبر 19
11262
UI is inappropriate when i install custom module in odoo19
action
الصورة الرمزية
0
نوفمبر 25
17
Guia Basica ¿Cómo puedo hablar con un asesor de Volaris?
action
الصورة الرمزية
0
نوفمبر 25
2
Need Advice For Migrate Thousands of Messy SKUs
action
الصورة الرمزية
0
نوفمبر 25
8
Pickup Date for E-Commerce تم الحل
action
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
نوفمبر 25
226
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "Github"
  • المشغل الآلي رنبوت
  • الترجمات
خدماتنا
  • استضافة أودو إس إتش
  • الدعم
  • الترقية
  • التطويرات المخصصة
  • التعليم
  • اعثر على محاسب
  • اعثر على شريك
  • كنْ شريكاً
معلومات عنا
  • شركتنا
  • أصول العلامة التجارية
  • اتصلْ بنا
  • الوظائف
  • فعاليات
  • بودكاست
  • مدونة
  • عملاء
  • قانوني • الخصوصية
  • الحماية
الْعَرَبيّة 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

أودو هو عبارة عن مجموعة من تطبيقات الأعمال مفتوحة المصدر التي تغطي جميع احتياجات شركتك، مثل: إدارة علاقات العملاء والتجارة الإلكترونية والمحاسبة والمخزون ونقاط البيع وإدارة المشاريع وما إلى ذلك.

ما يجعل من أودو مميزاً هو هدفه بأن يكون سهل الاستخدام للغاية ومتكاملاً تمامًا في الوقت ذاته.

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