Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Showing Error: "[object with reference: partner_id - partner.id] " for function return

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
1 Odpowiedz
6696 Widoki
Awatar
Pawan Kumar Sharma

Hello All,

I create a function for button(Send By SMS)  wizard action in Odoo10. In this function when i return value in the function following error shows on the screen. I also Define button action in sale order inherit file.  

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: partner_id - partner.id]     

So, What i return instead of code?

My Python and XML Code is Here:

Pythode Code:

import urllib2
import cookielib
from getpass import getpass
import sys
import os
from stat import *

class way2smsBase(models.Model):
_name = "way.base"
_rec_name = "user_name"

user_name = fields.Char(string="UserName", required=True)
password = fields.Char(string="Password", required=True)

class SaleMail(models.TransientModel):
_name = "sale.mail.wizard"
_description = "Sale Mail Wizard"

message = fields.Text(String="Message", size=140)
number = fields.Text(string="Receiver Number", required=True, size=12)
user_acc = fields.Many2one("way.base", 'ACC', required=True)
date_time = fields.Datetime(string="Date & Time", readonly=True)

def sendSms(self):
url = 'http://sunarctechnologies.com'
data = 'username=' + self.user_acc.user_name + '&password=' + self.user_acc.password + '&Submit=Sign+in'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-Agent',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120')]
try:
usock = opener.open(url, data)
except IOError:
raise Warning(_("Error pls Check account or mobile number"))
jession_id = str(cj).split('~')[1].split(' ')[0]
send_sms_url = 'http://site24.way2sms.com/smstoss.action?'
send_sms_data = 'ssaction=ss&Token=' + jession_id + '&mobile=' + self.number + '&message=' + self.message + '&msgLen=136'
opener.addheaders = [('Referer', 'http://site25.way2sms.com/sendSMS?Token=' + jession_id)]
try:
sms_sent_page = opener.open(send_sms_url, send_sms_data)
except IOError:
raise Warning(_("Error pls Check account or mobile number"))
self.date_time = str(datetime.now())
raise Warning(_("Message Sent"))

@api.one
@api.constrains('number')
def validatePhonenumber(self):
for phone in self:
if re.match("[0-9]", phone.number) == None:
raise Warning("Mobile number is not valid one, Please specify valid number")
return False
return True

@api.multi
def action_mail_add(self):
rec = self._context.get('active_ids', [])
print "REC"
if rec:
line_values = {'message': self.message,
'number': self.number,
#'user_acc': self.user_acc,
#'date_time': self.date_time,
}
print "Values:", line_values
#return line_values
return self.env['sale.order'].create(line_values)


XML Code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_sale_mail_wizard" model="ir.ui.view">
<field name="name">SaleMail</field>
<field name="model">sale.mail.wizard</field>
<field name="arch" type="xml">
<form string="Sales mail">
<sheet>
<!--<separator string="SMS"/> -->
<group string="Way2SMS" style="width: 40%%" col="2" colspan="2">
<field name="user_acc"/>
<field name="number"/>
<field name="message"/>
<field name="date_time"/>
</group>
</sheet>
<footer>
<button name="action_mail_add" type="object" String="Ok"
class="oe_highlight" icon="fa-commenting-o" confirm="Are you sure want to send sms"
attrs="{'invisible':[('date_time','!=',False)]}"
help="this button will send an sms "/>
<button string="Cancel" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>

<record id="action_view_sale_mail_wizard" model="ir.actions.act_window">
<field name="name">SaleMail</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.mail.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>

XML Code in Sales Order Inherit File:
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="custom_order_form">
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="name">Sale Order Pet Form</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<data>
<xpath expr="//button[@name='action_quotation_send']" position="after">
<button name="%(action_view_sale_mail_wizard)d" string="Send by SMS" type="action" class="btn-primary"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>


0
Awatar
Odrzuć
Awatar
Niyas Raphy (Walnut Software Solutions)
Najlepsza odpowiedź

Hi,

The problem is that you didn't give /mention the partner_id in your code while creation of the sale order.

partner_id is the required field in the sale.order model.

So here in this code,

 line_values = {'message': self.message,
                'partner_id' : 1,
'number': self.number,
#'user_acc': self.user_acc,
#'date_time': self.date_time,
}
print "Values:", line_values
return self.env['sale.order'].create(line_values)

Modify the code by adding the partner_id in the creation of sale order.

Thanks

2
Awatar
Odrzuć
Pawan Kumar Sharma
Autor

Hello Niyas,

Yes your point work for me.

Thanks

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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