-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequnces (auto increment a field) #305
Comments
you should call a method from odoo server.
public String getBillNoFromServer(Integer serverId) {
ODomain domain = new ODomain();
domain.add("id", "=", serverId);
OdooFields fields = new OdooFields();
fields.addAll(new String[]{"name"});
OdooResult result = getServerDataHelper().read(fields, serverId);
String billNo = "false";
if (result != null && result.has("name")) {
billNo = result.getString("name");
}
return billNo;
} odoo server code @api.model
def create(self, vals):
if not vals.get('name') or vals.get('name', 'New'):
vals['name'] = self.env['ir.sequence'].next_by_code('seq_bill_no') or '/'
record = super(Order, self).create(vals)
return record |
Hello is there any code or sample where i can insert data with the framwork?
Thank you.
…On 25 Feb 2017 18:47, "jiangzhixiao" ***@***.***> wrote:
you should call a method from odoo server.
1. you can use createOnServer method,in fact this method will call
*create* method on odoo server side. *create()* method will create a
prefix value, just like ** bill_no = PO20170225001**
2. you can use *getBillNoFromServer* to get the generated bill_no.
public String getBillNoFromServer(Integer serverId) {
ODomain domain = new ODomain();
domain.add("id", "=", serverId);
OdooFields fields = new OdooFields();
fields.addAll(new String[]{"name"});
OdooResult result = getServerDataHelper().read(fields, serverId);
String billNo = "false";
if (result != null && result.has("name")) {
billNo = result.getString("name");
}
return billNo;
}
odoo server code
@api.model
def create(self, vals):
if not vals.get('name') or vals.get('name', 'New'):
vals['name'] = self.env['ir.sequence'].next_by_code('seq_bill_no') or '/'
record = super(Order, self).create(vals)
return record
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#305 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVWl8egjVipGW0mpGRd0M68CMD856dAvks5rgD8FgaJpZM4Llklo>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
how to auto increment a field with a prefix ?
The text was updated successfully, but these errors were encountered: